在 C/C++ 中实现 RSA 的开源代码(使用库或编写我自己的)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4613361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 15:56:14  来源:igfitidea点击:

open source code for RSA implementation in C/C++ (Use library or write my own)

c++ccryptographyrsapublic-key-encryption

提问by ashmish2

I need open source code for RSA implementation (encrypt/decrypt and others). Can anyone suggest some.

我需要 RSA 实现的开源代码(加密/解密等)。任何人都可以推荐一些。

Edit: Is it good to use a open source library like opessl or write it your own (Library include other redundant stuff too)

编辑:使用像 opessl 这样的开源库还是自己编写它好(库也包括其他冗余的东西)

回答by Eugene Mayevski 'Callback

OpenSSL library is the obvious choice. CryptLibis another option, yet you need to check the license (it's quite specific).

OpenSSL 库是显而易见的选择。CryptLib是另一种选择,但您需要检查许可证(它非常具体)。

Regarding writing your own code: if you need onlyRSA, it's not large and you can write it yourself. However, RSA is almost never used by its own. Usually encryption is performed using random key and symmetric algorithm, and then the random key is encrypted with RSA. So if you want data encryption and decide to write your own stuff, you will be reinventing the wheel.

关于编写自己的代码:如果需要RSA,它并不大,可以自己编写。但是,RSA 本身几乎从未使用过。通常使用随机密钥和对称算法进行加密,然后使用 RSA 对随机密钥进行加密。因此,如果您想要数据加密并决定编写自己的东西,您将重新发明轮子。

回答by Adi Shavit

Crypto++ Library is a free C++ class library of cryptographic schemes.Amongst the many different encryption systems it supplies it also provides RSA.

Crypto++ Library 是一个免费的 C++ 加密方案类库。在它提供的许多不同的加密系统中,它还提供了 RSA。

In general, it is never a good idea to roll your own encryption/security code, unless this is what you are good at. Secure code is HARD, and even in established libraries loopholes, bugs and faults pop up every once in a while.

一般来说,滚动自己的加密/安全代码从来都不是一个好主意,除非这是你擅长的。安全代码很难,即使在已建立的库中也会时不时地出现漏洞、错误和故障。

回答by davka

have a look also at cryptopp. I use it and it is very convenient (haven't use the RSA though).

也看看cryptopp。我使用它,它非常方便(虽然没有使用过 RSA)。

see my other answers hereand here.

在此处此处查看我的其他答案。

回答by etarion

OpenSSL would be the standard choice. http://www.openssl.org/http://www.openssl.org/docs/crypto/rsa.html describes its API.

OpenSSL 将是标准选择。http://www.openssl.org/http://www.openssl.org/docs/crypto/rsa.html 描述了它的 API。