Hello! This is part of the code, regarding this issue:
#include <Crypto.h> // AES 128 CBC with pkcs7, RNG, SHA256 and SHA256HMAC
#include <base64.hpp>
#define HMAC_KEY_LENGTH 16
byte hmacKey[HMAC_KEY_LENGTH] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
byte message[HMAC_KEY_LENGTH] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30};
void setup() {
Serial.begin(115200);
SHA256HMAC hmac(hmacKey, HMAC_KEY_LENGTH);
hmac.doUpdate(message, HMAC_KEY_LENGTH);
byte authCode2[SHA256HMAC_SIZE];
hmac.doFinal(authCode2);
Serial.print("AUTHCODE2 IS : ");
for (byte i=0; i < SHA256HMAC_SIZE; i++)
{
if (authCode2[i]<0x10) { }
Serial.print(authCode2[i], HEX); //This prints 9CF3809536BBBC0B3D5536E6247C182BB1DC29C6DDC21D604CFAB92FDF9
}
String received = "9CF3809536BBBC0B3D5536E6247C182BB1DC29C6DDC21D604CFAB92FDF9";
//How to compare?
}
void loop() {
// put your main code here, to run repeatedly:
}
Basically i want to compare the byte array authCode2 with the string i have called received. I have tried converting the byte array to a String multiple times but it is always wrongly converted. I have tried once to convert the String into a byte array but it also fails when comparing the two of them... Does anyone know of a solution for this?
Thanks