You download a 5 GB ISO, write it to a USB drive and the installer fails halfway through. Was the download corrupted, or is it something else? Many downloads come with a long string of letters and numbers next to them: the hash. This guide shows you what it is, why MD5 no longer counts as secure, and how to check it on Windows, macOS and Linux with a single command.
In short
- A hash is a file’s fingerprint: change a single bit and the whole hash changes.
- Use SHA-256 to check integrity; MD5 and SHA-1 are broken against deliberate attacks.
- A hash only protects you if you get it from a trustworthy source; otherwise, the real guarantee is a digital signature.
What a hash function is
A hash function takes data of any size (a text, a photo, a multi-gigabyte ISO) and returns a result of fixed length. With SHA-256 it is always 256 bits, written as 64 hexadecimal characters.

It has four properties that make it useful:
- Deterministic: the same file always gives the same hash, on any computer and operating system.
- Avalanche effect: changing one bit produces a completely different hash, not a similar one.
- One-way: you cannot rebuild the file from its hash.
- Collision resistant: finding two different files with the same hash should be practically impossible.
Look at the avalanche effect with two texts that differ in just one letter:
SHA-256("hola") = b221d9dbb083a7f33428d7c2a3c3198ae925614d70210e28716ccaa7cd4ddb79
SHA-256("Hola") = e633f4fc79badea1dc5db970cf397c8248bac47cc3acf9915ba60b5d76b0e88f
They look nothing alike. That is why comparing a few characters at the start and end is enough to spot that something changed, although the correct way is to compare the whole hash.
A hash is not encryption. Encryption can be reversed with the key; a hash cannot be “decrypted”. It is not compression either: 64 characters cannot hold a 5 GB file.
Common algorithms
| Algorithm | Length | Hex characters | Secure today? | Reasonable use |
|---|---|---|---|---|
| MD5 | 128 bits | 32 | No (collisions since 2004) | Detecting accidental corruption, caches |
| SHA-1 | 160 bits | 40 | No (practical collision in 2017) | Legacy systems, compatibility |
| SHA-256 | 256 bits | 64 | Yes | Verifying downloads, signatures, certificates |
| SHA-512 | 512 bits | 128 | Yes | Same as SHA-256 |
The length of a published hash tells you which algorithm it is: 32 characters is almost certainly MD5, 64 is SHA-256.
Why MD5 and SHA-1 are no longer secure
In 2004 a team of researchers showed how to craft MD5 collisions: two different files with the same hash. Today a laptop can generate them in seconds. In 2012 the Flame malware used an MD5 collision to forge a certificate and pose as legitimate software.
SHA-1 held out longer, but in 2017 the first practical collision was published: two different PDFs with an identical SHA-1. Browsers and certificate authorities have since retired it.
What does this mean in practice?
- Against accidental corruption (a network drop, a disk with bad sectors), MD5 still catches the error. Random faults do not create collisions.
- Against deliberate tampering, MD5 and SHA-1 guarantee nothing. An attacker could prepare a malicious version with the same hash.
If a project publishes several hashes, always use SHA-256 or SHA-512.
How to calculate the hash on each system
Windows (PowerShell)
PowerShell includes Get-FileHash, which uses SHA-256 by default:
Get-FileHash .\ubuntu.iso
Get-FileHash .\ubuntu.iso -Algorithm SHA512
Instead of comparing by eye, let PowerShell do it for you. The -eq operator is case-insensitive, so it does not matter how the published hash is written:
(Get-FileHash .\ubuntu.iso).Hash -eq "paste_published_hash_here"
It returns True if they match.
Windows (Command Prompt)
If you prefer the classic console, certutil does the same:
certutil -hashfile ubuntu.iso SHA256
It accepts MD5, SHA1, SHA256, SHA384 and SHA512. Type it in uppercase to avoid surprises on older versions.
macOS
shasum -a 256 ~/Downloads/ubuntu.iso
You can also use shasum -a 512, or md5 if the project only publishes MD5.
Linux
sha256sum ubuntu.iso
sha512sum ubuntu.iso
md5sum ubuntu.iso
Command summary
| System | SHA-256 | Check against a file |
|---|---|---|
| Windows PowerShell | Get-FileHash file | Compare with -eq |
| Windows CMD | certutil -hashfile file SHA256 | Manual |
| macOS | shasum -a 256 file | shasum -a 256 -c file.sha256 |
| Linux | sha256sum file | sha256sum -c file.sha256 |
Checking with a .sha256 or SHA256SUMS file
Many projects do not put the hash on the web page but in a text file: ubuntu.iso.sha256, SHA256SUMS or similar. The format is simple: the hash, two spaces and the file name.

3f1a9c...e07b ubuntu.iso
Steps:
- Download the file and its
.sha256into the same folder. - Open a terminal in that folder.
- Run the check:
sha256sum -c ubuntu.iso.sha256
On macOS, shasum -a 256 -c ubuntu.iso.sha256. If all goes well you will see ubuntu.iso: OK. If it says FAILED, the file does not match.
When SHA256SUMS lists many files and you downloaded only one, add --ignore-missing so it does not complain about the rest:
sha256sum -c --ignore-missing SHA256SUMS
The limits of a hash: when it is not enough
This is what almost nobody explains. A hash proves your file is identical to the one that produced that hash. It does not prove who produced it.

If an attacker compromises the download site, they can change the ISO and also the hash published on the same page. Your check will pass perfectly and you will have installed the tampered version. It has happened in real cases of compromised servers.
Ways to reduce that risk:
- Get the hash through another channel: the official site over HTTPS when the download comes from a mirror, the project’s announcement, its code repository.
- Verify the digital signature when there is one. The project signs the hash file with its private key and you check it with its public key, which does not live on the same server:
gpg --verify SHA256SUMS.gpg SHA256SUMS
If the signature is valid and the key is the project’s official one, the hash file is authentic, and so is the ISO. On Windows, signed executables show the verified publisher under Properties › Digital Signatures.
| What you check | Detects corruption | Detects tampering |
|---|---|---|
| MD5 / SHA-1 | Yes | No |
| SHA-256 from the same site | Yes | Only if the site is not compromised |
| SHA-256 through another channel | Yes | Yes, in practice |
| Verified digital signature | Yes | Yes |
Common mistakes
- Hashing the wrong file: the browser renames it to
ubuntu (1).isoif one already existed. Check the exact name. - Comparing different algorithms: you calculate SHA-256 and compare it with a published MD5. They will never match. Look at the length.
- Download not finished yet: the hash of a half-downloaded file is useless. Wait until it completes.
- The .sha256 file in another folder:
-clooks for the file by the name listed inside, in the current directory. - Windows line endings: a
.sha256edited on Windows can showFAILEDon Linux because of the trailing carriage return. Download it again instead of editing it. - Assuming a correct hash means a safe program: it only guarantees it is the published file. If the original author included something malicious, the hash “certifies” that too.



