使用 C/C++ 使用 AES 加密解密

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2489379/
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-27 23:38:49  来源:igfitidea点击:

encrypt- decrypt with AES using C/C++

c++cencryptionaes

提问by Yannis Assael

How can I encrypt and decrypt a file with a 256 key AES in C or C++?

如何使用 C 或 C++ 中的 256 密钥 AES 加密和解密文件?

采纳答案by Thomas Pornin

If you are just after AES and do not mind losing flexibility (i.e. you will not replace it with another cryptographic algorithm at some time) then Brian Gladman's AES implementationis a popular choice (both for performance and portability). This is the kind of code which you embed in your own source code.

如果您刚开始使用 AES 并且不介意失去灵活性(即您不会在某个时候用另一种加密算法替换它),那么Brian Gladman 的 AES 实现是一个流行的选择(无论是性能还是可移植性)。这是您嵌入到自己的源代码中的那种代码。

On the external libraries front, you have plenty of choice, including NSS, OpenSSL, Crypto++... the latter is specifically designed for C++, while the two others are meant for C.

在外部库方面,您有很多选择,包括NSSOpenSSLCrypto++……后者是专门为 C++ 设计的,而另外两个是为 C 设计的。

回答by pcunite

LibTomCrypt I think may be one of the easiest to use. I know so little about this type of work, but I was able to get it up and running fairly quickly. The thing about encryption is not the actual functions, but the flow and what to do with the information as you encrypt and decrypt. That is what makes this type of work hard, not just the fact you can encrypt things.

LibTomCrypt 我认为可能是最容易使用的之一。我对这种类型的工作知之甚少,但我能够相当快地启动并运行它。关于加密的问题不是实际功能,而是流程以及在加密和解密时如何处理信息。这就是使此类工作变得困难的原因,而不仅仅是您可以加密事物的事实。

http://github.com/libtom/libtomcrypt

http://github.com/libtom/libtomcrypt