This repository contains code that would enable you to easily integrate the AES encryption algorithm in CBC mode to your project.
You can also get this code from SourceForge: https://sourceforge.net/projects/aes-in-cbc-mode-for-mcus/
The code was successfully tested on the following boards:
- STM32F407VET6
- Teensy 4.1
- ESP32
- ESP8266
- RTL8720DN
Serial.println("\nEncryption/Decryption Test:");
String plaintext = "This string is encrypted with AES-256 in Cipher Block Chaining mode!"; // String to be encrypted
int iv[16]; // Initialization vector
for (int i = 0; i < 16; i++){
iv[i] = random(256); // Fill iv array with random numbers. I suggest you use a more secure method of random number generation!!!
}
encrypt_string_with_aes_in_cbc(plaintext, iv); // Function for encryption. Takes the plaintext and iv as the input.
Serial.println("\nCiphertext");
Serial.println(string_for_data);
String ciphertext = string_for_data; // Back the ciphertext up
decrypt_string_with_aes_in_cbc(ciphertext); // Decrypt data
Serial.println("Plaintext:");
Serial.println(string_for_data);
When you call either "encrypt_string_with_aes_in_cbc(plaintext, iv)" or "decrypt_string_with_aes_in_cbc(ciphertext)" the string "string_for_data" is cleared.
The library with the implementation of aes by zhouyangchao is the property of its rightful owner.

