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

-- 
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


Reply via email to