1

I have sha1sum installed on an Ubuntu 16.04 system and used it like this to compute an sha1 sum:

root@computer:# echo 1234 | sha1sum
1be168ff837f043bde17c0314341c84271047b31  -

also I computed the sum on a file whose only content was the same '1234':

root@computer:# sha1sum /tmp/x
1be168ff837f043bde17c0314341c84271047b31  /tmp/x

and I got the same answer both times. Then I went to a couple of websites that will compute sha1 hashes for you. I went to https://passwordsgenerator.net/sha1-hash-generator/ and input '1234' and got this:

7110EDA4D09E062AA5E4A390B0A572AC0D2C0220

I went to http://www.sha1-online.com and I also got

7110eda4d09e062aa5e4a390b0a572ac0d2c0220

So...how do I explain this discrepancy?

1 Answer 1

2

You have a newline in the echo and file cases.

$ printf '1234' |sha1sum
7110eda4d09e062aa5e4a390b0a572ac0d2c0220  -
$ printf '1234\n' |sha1sum
1be168ff837f043bde17c0314341c84271047b31  -
1
  • 1
    I just discovered this, and that 'echo' has an '-n' flag to eliminate the new line: root@computer:# echo -n 1234 | sha1sum 7110eda4d09e062aa5e4a390b0a572ac0d2c0220 -
    – Craig
    Commented Mar 6, 2018 at 4:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .