Luke Oliff.

TIL: Checking File Integrity With shasum

·TIL·1 min read·Luke Oliff

Downloaded a file and wondered if it got corrupted in transit? shasum tells you.

shasum -a 256 model.bin

Output is a 64 character hex string. Compare it against the checksum published by the source.

shasum -a 256 model.bin | grep -c abcdef1234567890

For automation, grep the expected hash against the output. Exit code 0 means match, 1 means corrupted or wrong file.

shasum -c checksums.txt

If you have a file of hash-filename pairs, -c verifies every file in the list. Useful after bulk downloads of model files or datasets.

What is the difference between SHA-256 and SHA-512?

SHA-512 produces a longer hash (128 characters) for stronger collision resistance. SHA-256 is faster and sufficient for most file integrity checks.

Is shasum available on macOS?

Yes. Built into macOS and Linux. No installation needed.