Saturday, 17 August 2013

Why am I not getting the sha256 right?

Why am I not getting the sha256 right?

I am using crypto++ library for some exercise. I am expecting the same
output as from the sha256sum tool invoked from the shell.
// typedef unsigned char byte;
byte out[CryptoPP::SHA256::DIGESTSIZE];
byte in=65; // 'A'
CryptoPP::SHA256().CalculateDigest(out, &in, 1);
for(int i=0; i < CryptoPP::SHA256::DIGESTSIZE; i++)
std::cout << std::hex << (int)out[i];
std::cout << std::endl;
559aead08264d5795d399718cdd5abd49572e84fe55590eef31a88a08fdffd
$ echo A | sha256sum
06f961b802bc46ee168555f066d28f4f0e9afdf3f88174c1ee6f9de004fc30a0
Why are the two not equal?

No comments:

Post a Comment