Vadym...
On Mon, 2004-11-22 at 18:30 +0800, Vadym Fedyukovych wrote:
> 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
Doh! You know I did actually consider that but I assumed (eek!) sha1sum
would have ignored that in my stdin. Thanks for confirming my stupidity
to quickly! Oh, cool name BTW!
Regards
Jim
--
James Vanns BSc (Hons) MCP
Linux Systems Administrator
Software Engineer (Linux / C & C++)
Canterbury Christ Church University College
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x24045370