#include <AESLib.h>

//#include <Esp.h>


//#include <AES.h>
//#include "./printf.h"





const int size_mesg = 256;

uint8_t key[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};


void printArray(byte *mes, int n) {
  for (byte i = 0; i < n; i++) {
    Serial.print(mes[i]);
    Serial.print(" ");
  }
  Serial.println();
}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(57600);
}

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

  byte plain[size_mesg];

  randomSeed(334);
  for (int i = 0; i < size_mesg; i++) {
    plain[i] = random(255);
  }

 //Serial.print("plain    :");
 // printArray(plain,size_mesg);



    unsigned long ms1 = micros ();
    for(int i=0;i<size_mesg;i+=16) {
      aes128_enc_single(key, &plain[i]);
    }
    Serial.print("Encryption took: ");
    Serial.println(micros() - ms1);
    //Serial.print("encrypted:");
    //printArray(plain,size_mesg);

    ms1 = micros ();  
    for(int i=0;i<size_mesg;i+=16) {
      aes128_dec_single(key, &plain[i]);
    }
    Serial.print("Decryption took: ");
    Serial.println(micros() - ms1);
    //Serial.print("decrypted:");
    //printArray(plain,size_mesg);
  
  delay(2000);
}