1

Why the difference in the following?

$ echo -n "foo" | openssl dgst -sha1 -hmac "key"
(stdin)= 9fc254126c2b1b7f106abacae0cb77e73411fad7
$ echo -n "foo" | sha1sum 
0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33  -
Marcus Junius Brutus
  • 4,587
  • 11
  • 44
  • 65

1 Answers1

2

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.

Oli
  • 16,068