Check a file’s SHA-256 hash, and what it proves
Drop the file on the hash generator and compare its SHA-256 with the one on the maker’s page. If every character is the same, you have exactly the file they published. The file is read on your device and not sent anywhere, so it works for evidence and contracts too.
What a hash is
A hash is a fingerprint of a file’s bytes. Change one letter in a hundred megabytes and the whole fingerprint changes. It does not depend on the name or the date, so two copies with different names have the same hash. You cannot rebuild the file from it.
The three letters abc have the SHA-256 ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad. Write abd instead and nothing of that remains.
Compare
- Copy the published hash from the maker’s own site, not from the page you downloaded from.
- Open the hash generator and press Choose files. Several files are fine.
- Press Copy and paste the result in a plain note beside the published one.
- Search the note for the published hash. Found twice means they match.
- If they differ, download again and repeat once. Still different: do not open the file.
Searching is better than staring. People check the first four and last four characters, and that is exactly what an attacker would try to match.
Which one to use
The page gives five at once: MD5, SHA-1, SHA-256, SHA-384 and SHA-512. Use the one the maker published. If you may choose, take SHA-256. MD5 and SHA-1 can be forged on purpose, so they only show accidents.
What a match proves
It proves the file is the same as the one that was hashed. It does not prove that the file is good, or that the page you copied the hash from is honest. Someone who can replace the download can replace the number beside it. That is why a hash on a different site, in a signed message or in a package list counts for more. For a PDF signed with a certificate, Verify signature goes further: it shows who signed and whether anything changed afterwards.
Everyday uses
- A download of an operating system or a wallet program.
- A delivery. Send the hash of the final artwork in the e-mail. If anyone asks later which file was approved, it settles the matter.
- Two copies. Are these two 4 GB videos the same? Hash both instead of watching both.
- A backup. Hash before, hash after a year. Silent damage shows.
- Evidence. Hash photos the day you take them and mail the list to yourself.
What goes wrong
The case differs. 3028AB and 3028ab are the same; compare without regard to case.
The hash is of the zip, not the file inside. Hash what they hashed.
A text file differs by one line ending. Git or a mail program changed Windows line endings. To a hash that is a different file.
A picture from a chat. Chat apps save pictures again. It will never match.
The browser runs out of memory on many gigabytes. Use the computer’s own command: certutil -hashfile file SHA256 on Windows, shasum -a 256 file on a Mac, sha256sum file on Linux.
Check the checker
Make a text file with the three letters abc and no line break. Its SHA-256 is the one shown above, in every correct program. If yours shows something else, your editor added a line break at the end, which is a lesson in itself.
Hashes do not hide anything. To keep others out of a file, use a password on a PDF, and to see what is inside an archive before you trust it, open it without running it.
Questions
Is MD5 still fine?
For noticing a broken download, yes. For anything where someone may cheat, no: use SHA-256.
Can two files have the same SHA-256?
In theory. No one has found a pair, so a match means the same file.