I'm struggling with this code though and the example isn't really an example and doesn't show its usage. All I want is to define my own function to hash a string and return a string representing its SHA256 hash.
So you suggest to try and construct the output in similar way to lines 166-181 in TestSHA256.ino? Can you give a specific example because I'm not very much experienced with C language
No specific example - I'm also just looking at the code you posted.
It appears to create a hash, store that in the variable result, and do a comparison on that. You have to read the code more carefully, and reference to the manual of the library itself to confirm that's indeed what those functions do.
Ok -
So I was struggling with the code inside function testHash_N() in TestSHA256.ino, which does exactly that: create a hash (from struct TestHashVector data) and compare it with the precomputed hash (from struct TestHashVector hash[]).
The hash seems to be computed in lines 89-96. But this creates a reference to memory or something like that. I just want to take the actual hash string result, so for testVectorSHA256_1 in the example, I would need to have a string = "ba7816bf....15ad" as the result..
Thanks for helping