2

I'm attempting to replicate the values found here http://www.nsrl.nist.gov/testdata/

SHA-256 should hash "abc" out to

 BA7816BF 8F01CFEA 414140DE 5DAE2223 B00361A3 96177A9C B410FF61 F20015AD

but under linux with sha256 sum I am getting this.

edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb

adam@adam-desktop:~/code/android-casual/trunk/CASUALcore$ echo "abc">./test.tmp
adam@adam-desktop:~/code/android-casual/trunk/CASUALcore$ sha256sum test.tmp
edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb  test.tmp
adam@adam-desktop:~/code/android-casual/trunk/CASUALcore$ echo "abc"|sha256sum
edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb  -
1

1 Answer 1

6

That's because echo appends a newline to the string. Use echo -n instead:

$ echo "abc" | shasum -a 256
edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb  -
$ echo -n "abc" | shasum -a 256
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad  -

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.