Download pages often show a long string of characters next to a file — something like 5d41402abc4b2a76b9719d911017c592 — labelled MD5 or SHA-256. Most people ignore it. But that string is a hash, and it's one of the most quietly important tools in computing: it verifies downloads, protects stored passwords, and underpins digital signatures.
This guide explains what hash functions do, what MD5, SHA-1, and SHA-256 actually are, and how to use them in practice.
What a hash function does
A hash function takes input of any size — a single word, a 4 GB video file — and produces a fixed-size string of characters called a hash (or digest). For example, the SHA-256 hash of the word "hello" is:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Change one letter — "hellO" — and the hash becomes completely different, unrecognisable from the first. This dramatic change from a tiny input change is called the avalanche effect, and it's deliberate. Good hash functions have four key properties:
- Deterministic: the same input always produces the same hash.
- One-way: you can't reverse a hash back into the original input. There's no "unhash" button.
- Avalanche effect: tiny input changes produce wildly different hashes.
- Collision-resistant: it's practically impossible to find two different inputs with the same hash.
Because of these properties, a hash acts as a fingerprint for data. If two files have the same SHA-256 hash, you can be confident they're byte-for-byte identical — without comparing the files themselves.
MD5, SHA-1, and SHA-256: what they are
These are three generations of hash algorithms, and the differences matter:
- MD5 (1992) produces a 128-bit hash, shown as 32 hexadecimal characters:
5d41402abc4b2a76b9719d911017c592is the MD5 of "hello". It was the workhorse of the 90s and 2000s. Problem: researchers demonstrated practical collision attacks against MD5 — two different files engineered to share one MD5 hash. It's now considered broken for security purposes. - SHA-1 (1995) produces a 160-bit hash (40 hex characters). It replaced MD5 in many systems, but in 2017 Google demonstrated the first practical collision ("SHAttered"). SHA-1 is now deprecated for security use too.
- SHA-256 (2001, part of the SHA-2 family) produces a 256-bit hash (64 hex characters). No practical attacks exist against it. It's the current standard for security-sensitive hashing — used in TLS certificates, Bitcoin, and file verification.
The short version: MD5 and SHA-1 are fine for non-security checksums (like quickly spotting accidental file corruption), but anything security-related should use SHA-256 or newer (SHA-3, BLAKE2/3 exist too). If you see software still using MD5 for password storage or signatures in 2026, that's a red flag about the software, not the algorithm's charm.
What hashes are actually used for
1. Verifying downloads (checksums)
When you download software, the publisher publishes the file's SHA-256 hash. After downloading, you hash the file yourself with a hash generator and compare. Match = the file arrived intact and untampered. Mismatch = corrupted download or something malicious — don't install it.
2. Storing passwords safely
Responsible services never store your actual password. They store a hash of it. When you log in, they hash what you typed and compare hashes. Because hashing is one-way, a database breach exposes hashes, not passwords — and with proper techniques (unique salts per user plus slow algorithms like bcrypt or Argon2), even those hashes resist cracking. Note: plain MD5/SHA-256 are too fast for password storage — attackers can try billions of guesses per second — which is why dedicated password-hashing algorithms exist.
3. Digital signatures and certificates
Signing software or documents involves hashing the content and encrypting the hash with a private key. Anyone can verify the signature with the public key — proving both who signed it and that nothing changed since. The HTTPS padlock in your browser rests on this machinery.
4. Deduplication and integrity in storage
Backup systems and version control (Git uses SHA-1/SHA-256 internally) hash content to detect duplicates and corruption. Two identical files, one stored copy; one flipped bit, instant detection.
Generating and comparing hashes: a practical walkthrough
- Pick the algorithm. Default to SHA-256 unless you have a specific reason otherwise (e.g. matching a published MD5 checksum).
- Generate the hash of your text or file with a hash generator — ideally one that runs locally in your browser so your data never leaves your machine.
- Compare carefully. When checking against a published hash, compare the entire string, not just the first few characters. Attackers can craft files whose hashes share a prefix.
- Mind the encoding. Hashing the text "hello" vs "hello\n" (with a trailing newline) gives different results. When a checksum doesn't match, invisible whitespace differences are a common innocent cause — re-check how the original was generated before assuming tampering.
Common misconceptions
- "Hashing encrypts data." No — encryption is reversible with a key; hashing is one-way by design. They're different tools for different jobs.
- "MD5 is fine, it's just a checksum." For accidental-corruption detection, yes. But MD5 checksums provide zero protection against deliberate tampering, since collisions can be engineered. Prefer SHA-256 for anything downloaded from the internet.
- "Two files with the same hash must be identical." Technically, collisions are theoretically possible — but for SHA-256, finding one by accident is less likely than picking the same grain of sand twice on all of Earth's beaches. For practical purposes, identical SHA-256 = identical file.
- "I can recover data from its hash." You can't. The only "recovery" is guessing inputs and re-hashing (a brute-force or dictionary attack) — which is exactly what password hashing defences are designed to make expensive.
Frequently asked questions
Which hash algorithm should I use?
SHA-256 for anything new or security-related. MD5 or SHA-1 only when you're matching an existing published checksum that you didn't choose, or for non-security internal checks where speed matters and tampering isn't a threat model.
Why do hashes look like random letters and numbers?
They're shown in hexadecimal — base-16 notation using 0–9 and a–f. A 256-bit hash is 64 hex characters. The "random" appearance is the point: the output should be indistinguishable from random noise, revealing nothing about the input.
Can hashing protect my files from being read?
No. A hash doesn't hide or encrypt anything — anyone with the file can compute its hash, and the hash can't recreate the file. If you need confidentiality, use encryption. Hashes provide integrity (detecting change), not secrecy.
How long does it take to hash a large file?
Hashing is fast — modern hardware computes SHA-256 at hundreds of megabytes per second, so a 1 GB file takes a few seconds. That's why it's practical to verify every download: the check costs almost nothing.