Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

encrypt- decrypt with AES using C/C++

Tags:

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

like image 663
Yannis Assael Avatar asked Mar 22 '10 00:03

Yannis Assael


People also ask

How encrypt AES CBC?

To encrypt using AES-CBC: Instantiate the CBC block cipher class with the AES implementation class. Initialize it with the key and Initialization Vector (IV) for encryption. Process each block of the padded plaintext being encrypted.

Do you need the IV to decrypt AES?

Yes, you must provide the same IV for encryption and decryption.


1 Answers

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 implementation is a popular choice (both for performance and portability). This is the kind of code which you embed in your own source code.

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.

like image 152
Thomas Pornin Avatar answered Oct 09 '22 14:10

Thomas Pornin