James Vanns wrote:
All,
I have the following function:
const string Base::checksum (const string &p_data) const {
string s;
byte digest[SHA1::DIGESTSIZE];
const uint length = p_data.size ();
const byte *message = reinterpret_cast<const byte *> (p_data.data ());
SHA1 ().CalculateDigest (digest, message, length);
StringSource (digest, SHA1::DIGESTSIZE, true, new HexEncoder (new
StringSink (s)));
return s;
}
And when I do
Base o;
cout << o.checksum ("123") << endl;
I get a different output to the UNIX tool sha1sum.
Crypto++: 40BD001563085FC35165329EA1FF5C5ECBDBBEEF
sha1sum: a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0
Have I actually used the SHA-1 implementation here correctly?
Cheers
Jim
echo -n 123 | ...bin/openssl sha1
40bd001563085fc35165329ea1ff5c5ecbdbbeef
echo 123 | ...bin/openssl sha1
a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0