I use this library to GitHub - DavyLandman/AESLib: Arduino Library for AES Encryption (source based on avr-crypto-lib)
here is the code
#include <AESLib.h>
void setup() {
Serial.begin(57600);
Serial.println("Welcome to Encryption");
uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};//168 = 128 bytes
uint16_t in[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
uint8_t IV[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
char data[] = "The wifi Password is Bobby8990!."; //chars == bytes
unsigned long start1 = micros();//When the timer starts running before encryption
//aes128_enc_single(key, data);// encryption algorithm
//aes128_enc_multiple(key, data, in);//multiple encryption algorithm
aes128_cbc_enc(key, IV, data, in);//multiple cbc (single calls)
Serial.println("encrypted:");
for (int i=0; i<sizeof(data);i++)
{
Serial.print(data&0xFF, HEX);*
-
}*
-
Serial.println(" ");*
-
unsigned long diff1 = micros() - start1;// End time - start time*
-
Serial.println(diff1);// Overall time used for encryption*
-
unsigned long start2 = micros(); // timer starts running for decryption*
-
//aes128_dec_single(key, data);*
-
//aes128_dec_multiple(key, data, in);*
-
aes128_cbc_dec(key, IV, data, in);*
-
Serial.println("decrypted:");*
-
Serial.println(data);*
-
Serial.println("Decryption time");*
-
unsigned long diff2 = micros()- start2;*
-
Serial.println(diff2);*
-
Serial.println("Time difference");*
-
Serial.println(diff2-diff1);// time for encryption and decryption to occur.*
-
Serial.println("Total time");*
-
Serial.println(diff2+diff1);*
}
void loop(){
}
The program works very well with data size 16,24 but it is not properly working for 32 all in Arduino Mega2560
but the program works perfectly well in Arduino Uno
i would like to know if i am the one doing nonsense.