How do I check the SHA1 hash of a file?

sha1sum

Print or check SHA1 (160-bit) checksums. With no FILE, or when FILE is -, read standard input.

sha1sum {file}

If you want to send the file together with its sha1sum output redirect the output to a file:

sha1sum {file} > {file}.sha1

Send both files and the other party can do a...

sha1sum -c {file}.sha1

It should show OK if the sha1 is correct.


Without creating local file:

$ sha1sum filename

8dd10000eb1b768800000e1d2fe1c3100005d2dc *filename

For checking, go to the directory that contains filename and run this command:

echo "8dd10000eb1b768800000e1d2fe1c3100005d2dc *filename" | sha1sum -c -

Its very simple.

Navigate to the terminal and key in:

sha1sum  filename

to check a sha1 hash use:

sha1sum -c filename.sha1

The check argument generates the sha1 hash of filename and compares it with the value stored in filename.sha1. If it matches OK is displayed and the exit code for the command is 0


For those who are on mac and don't have coreutils/sha1sum installed.

openssl sha1 <file>

Example:

$ openssl sha1 `mktemp`
SHA1(/tmp/tmp.jkyfOWma3t)= da39a3ee5e6b4b0d3255bfef95601890afd80709