Monday, February 1, 2016

SHA-2: Command Comparison

Using command "shasum":
$ echo -n "test" | shasum -a 256
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 -


Using command "openssl dgst":
$ echo -n "test" | openssl dgst -sha256
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08


Using command "openssl dgst" with option "hmac" with secret key:
$ echo -n "test" | openssl dgst -sha256 -hmac \"SECRET\"
c5790721d9fc3b84a46034c7b80d7b01d92f41a2847e67d17d8cc6cc97a6c7ad