#include "MD5.h"
#include "mbedtls/base64.h"
const byte md5Len = 16; // 16 bytes hash
const byte b64Len = ((md5Len + 2) / 3) * 4 + 1; // max length for the base64 encode
void setup() {
Serial.begin(115200);
//generate the MD5 hash for our string
unsigned char* hash = MD5::make_hash("Hello World"); // 128 bits hash = 16 bytes
Serial.print("Hash = ");
for (byte i = 0; i < md5Len; i++) {
if (hash[i] < 0x10) Serial.write('0');
Serial.print(hash[i], HEX);
Serial.write(' ');
}
Serial.println();
unsigned char b64Out[b64Len];
size_t b64OutLen;
mbedtls_base64_encode(b64Out, b64Len, &b64OutLen, hash, md5Len);
Serial.print("Base64 = ");
Serial.println((char*) b64Out);
free(hash);
}
void loop() {}