the sketch just print the values of the hash
i need to store it in a char array
i tried to check what is stored in hash but it was useless and there were different value from what is printed on the serial monitor
when i tried saving an array directly from the function sha256.result it gives me the un encoded output of the hash
i need to save the encoded version of the hash
when i tried saving an array directly from the function sha256.result it gives me the un encoded output of the hash
i need to save the encoded version of the hash
Where in the code do you store anything in an array?
printHash(Sha256.result());
What, EXACTLY, is the return type of result()?
Serial.print("0123456789abcdef"[hash[i]>>4]);
In English, what, exactly, do you think that statement is doing? It seems like you want to store the same value you print, in an array. So, why don't you?
PaulS:
Where in the code do you store anything in an array?
printHash(Sha256.result());
What, EXACTLY, is the return type of result()?
Serial.print("0123456789abcdef"[hash[i]>>4]);
In English, what, exactly, do you think that statement is doing? It seems like you want to store the same value you print, in an array. So, why don't you?
cz i am not familiar with c++ or do not know even what to search to know how this statement is written or its meaning
#include "sha256.h"
void setup(void)
{char encoded[64];
Serial.begin(9600);
// this is actually the RFC4231 4.3 test
Sha256.init();
Sha256.print("123");
uint8_t * result = Sha256.result();
for (int i = 0; i < 32; i++) {
Serial.print("0123456789abcdef"[result[i] >> 4]);
Serial.print("0123456789abcdef"[result[i] & 0xf]);
for(int i = 0; i < 64; i+=2)
{
encoded[i] = "0123456789abcdef"[result[i / 2] >> 4];
encoded[i + 1] = "0123456789abcdef"[result[i / 2] & 0xf];
}
}
Serial.print("\n");
for(int z = 0; z < 64; z++)
Serial.print(encoded[z]);
}
void loop(void)
{}
this is the code that worked for me finally
thank u fo every one who tried to help me
special thanks to daknuett for his support after posting my question at his github