AES test encrypted and decrypted

from https://github.com/DavyLandman/AESLib/blob/master/README.md


#include <AESLib.h>

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
uint8_t key[] = {0,0,0,0,0};
char data[] = "0123456789012345"; //16 chars == 16 bytes
aes128_enc_single(key, data);

  Serial.print(F("encrypted:")); printBytes(data, 16);
//Serial.println(data);
aes128_dec_single(key, data);
//Serial.print("decrypted:");
//Serial.println(data);
  Serial.print(F("decrypted:")); printBytes(data, 16);
}

void loop() {
  // put your main code here, to run repeatedly:

}

void printBytes( byte *array, byte arrayLength)
{
    Serial.print("[");
      for (uint32_t i = 0; i < arrayLength; i++) {

        Serial.print(array[i], HEX);
        Serial.print(" ");
      }
      Serial.println("]");
}

留言

熱門文章