#include <mbedtls/aes.h>
mbedtls_aes_context aes;
unsigned char key[] = "1234567890123456";
unsigned char iv[] = "1234567890123456";
String bla = "testme";
unsigned char out[16];
unsigned char inp[16];
int size = sizeof(bla);
for (int i = 0; i < size; i++)
{
inp[i] = bla[i];
}
for (int i = size; i < 16; i++)
{
inp[i] = 0;
}
mbedtls_aes_init(&aes);
mbedtls_aes_setkey_enc(&aes, key, 128);
mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, 16, iv, inp, out);
1
yangbonis 2020-09-16 01:19:23 +08:00 via iPhone
不该 decrypt 一下,比较一下吗
|
2
yangbonis 2020-09-16 01:35:33 +08:00 via iPhone
看了下手册,cbc 模式 iv 全零,ecb 模式不用 iv 。
|