Why the difference in the following?

$ echo -n "foo" | openssl dgst -sha1 -hmac "key"
(stdin)= 9fc254126c2b1b7f106abacae0cb77e73411fad7
$ echo -n "foo" | sha1sum 
0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33  -

The -hmac "key" is what does it. Adding a HMAC is sort of like salting the data. It's not quite the same but you're changing how the hash is calculated. Thus you end up with a different result.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.