#include "esp_log.h"
#include "mbedtls/aes.h"
#include <stdio.h>
#include <string.h>
#include <sodium.h>
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
//Serial.println("test");
char enc_key[33] = "12345678901234567890123456789012";
char enc_iv[17] = "1234567890123456";
char *enc_input = "EncryptionString";
encrypt_string(enc_input, (uint8_t *)enc_key, (uint8_t *)enc_iv);
}
void encrypt_string(const char *input, uint8_t *key, uint8_t *iv)
{
char output[16]; //char array store output
mbedtls_aes_context aes; //aes is simple variable of given type
mbedtls_aes_init(&aes);
mbedtls_aes_setkey_enc(&aes, key, 256);//set key for encryption
//this is cryption function which encrypt data
int result = mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, strlen(input), iv,
(unsigned char *)input, (unsigned char*)output);
//print output hex buffer on console
//Serial.println(HEX, output);
printf("%x\n", output);
}
void loop() {
// put your main code here, to run repeatedly:
//delay(250); // this speeds up the simulation
}