i am trying to copy the output of hash output to another array and here is my code
#include "sha256.h"
#include <Arduino.h>
#include "./printf.h"
char arr[33] ;
uint8_t* hash;
void printHash(uint8_t* hash) {
for (int i=0; i<32; i++) {
Serial.print("0123456789abcdef"[hash[i]>>4]);
Serial.print("0123456789abcdef"[hash[i]&0xf]);
}
Serial.println();
}
void setup() {
Serial.begin(9600);
}
void loop() {
char xx[21];
String str ="12345678901234567890";
str.toCharArray(xx, 21);
Sha256.initHmac((uint8_t*)xx,21);
Sha256.print("node 1");
hash=Sha256.resultHmac();
for( int j=0;j<32;j++)
{arr[j]=hash[j];
arr[32]='\0';
Serial.print(arr[j],HEX);
}
Serial.print('\n');
}
when i print hash i get the expected digest
A22E26CD62834B901E43F4D871D063B51CDE769D3396D1774EEDDBD892B73F91
but when i print arr[j] i a strange digest
FFFFFFA22E26FFFFFFCD62FFFFFF834BFFFFFF901E43FFFFFFF4FFFFFFD871FFFFFFD063FFFFFFB51CFFFFFFDE76FFFFFF9D33FFFFFF96FFFFFFD1774EFFFFFFEDFFFFFFDBFFFFFFD8FFFFFF92FFFFFFB73FFFFFFF91
how can i fix that ?
thx in advance for ur help