MD5 vs SHA-256: What Hashing Actually Does and When You Need It
The difference between hashing algorithms, why MD5 is considered broken for security, and when a checksum is still fine.
A hash function takes any input (a word, a password, a 4 GB video file) and produces a short, fixed-length string that acts as its fingerprint. The same input always produces the same hash, and changing even one character produces a completely different one. You can't turn a hash back into the original input. Those properties make hashing one of the most widely used tools in computing, and they are also why choosing the right algorithm matters. This guide explains what hashing is for, how MD5, SHA-1 and SHA-256 differ, and the one place where people most often get it wrong.
What a hash looks like
Here are the hashes of the word hello:
- MD5:
5d41402abc4b2a76b9719d911017c592 - SHA-1:
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d - SHA-256:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Now change one letter. The MD5 of Hello, with a capital H, is 8b1a9953c4611296a827abf8c47804d7, with no resemblance to the first. This "avalanche effect" is what makes hashes useful as fingerprints: there is no such thing as a nearly matching hash.
What hashing is used for
- Checking downloads: software publishers list the SHA-256 of their installers. If the hash of your download matches, the file is exactly what they published, with no corruption and no tampering.
- Detecting changes: compare the hash of a file today with its hash last month to know instantly whether anything changed, without comparing the files byte by byte.
- Finding duplicates: two files with the same hash are, for practical purposes, identical. Backup and storage systems use this to avoid storing the same data twice.
- Identifying content: Git names every commit and file by its hash; caches and content-delivery systems use hashes as keys.
- Digital signatures and certificates: documents are hashed and the hash is what gets signed.
MD5: fast, short, and broken for security
MD5 produces a 128-bit hash (32 hex characters) and is very fast. It is also cryptographically broken. Since 2004 researchers have been able to create two different inputs with the same MD5 hash (a "collision"), and the attack became practical enough that the Flame malware used a forged MD5-based certificate in 2012 to pass itself off as Microsoft software.
So MD5 must never be used where an attacker might benefit from a collision: certificates, signatures, passwords or security tokens. It is still fine for non-adversarial jobs, such as spotting accidental corruption, cache keys, or matching an old checksum that was published in MD5.
SHA-1: retired
SHA-1 produces a 160-bit hash. It was the standard for years, but in 2017 researchers demonstrated a practical collision (the "SHAttered" attack: two different PDFs with the same SHA-1). Browsers and certificate authorities have dropped it. You will still meet it in older systems and in Git's original design, but don't choose it for anything new.
SHA-256: the current standard
SHA-256 is part of the SHA-2 family and produces a 256-bit hash (64 hex characters). There are no known practical collision attacks against it. It is the default for file integrity, TLS certificates, code signing and blockchains, and the right choice whenever you need a hash that should hold up against a deliberate attacker.
| Algorithm | Output | Security status | Still fine for |
|---|---|---|---|
| MD5 | 128-bit | Broken (collisions since 2004) | Accidental corruption checks, cache keys |
| SHA-1 | 160-bit | Broken (practical collision 2017) | Legacy compatibility only |
| SHA-256 | 256-bit | Secure | Integrity, signatures, general use |
The big mistake: hashing passwords with SHA-256
It sounds right to store passwords as SHA-256 hashes, but it isn't. SHA-256 is designed to be fast, and fast is exactly what an attacker with a stolen database wants. Modern graphics cards compute billions of SHA-256 hashes per second, so common and short passwords fall quickly even when salted.
Passwords need hash functions designed to be slow and memory-hungry: Argon2id, bcrypt or scrypt. They include a unique salt per password and a tunable cost, so each guess costs an attacker real time. If you build a login system, use your framework's built-in password hashing (almost all now use one of these) rather than calling SHA-256 yourself.
Hashing is not encryption
Encryption is reversible with the right key: you encrypt a file so the recipient can decrypt it. Hashing is one-way: there is no key and no way back. And encoding, such as Base64, is neither; it is reversible by anyone. If you need to protect a document, encrypt it, for example with the Protect PDF tool. If you need to verify data hasn't changed, hash it.
How to generate a hash
- Open the Hash Generator.
- Paste or type your text.
- MD5, SHA-1 and SHA-256 are calculated at once. Copy the one you need.
Hashing runs in your browser, so whatever you fingerprint stays on your machine.
Verifying a downloaded file
The Hash Generator works on text. To hash a file, your operating system has a built-in command:
- Windows:
certutil -hashfile installer.exe SHA256 - macOS:
shasum -a 256 installer.dmg - Linux:
sha256sum installer.tar.gz
Compare the output with the hash on the publisher's site. Every character must match. Only compare against a hash from the official site, because an attacker who can replace the file can replace a hash posted next to it on an untrustworthy mirror.
Frequently asked questions
Why does another tool give a different hash for the same text?
The bytes differ even if the text looks the same: a trailing newline, Windows vs Unix line endings, an invisible character or a different text encoding. The algorithm isn't wrong; the input is.
Can a hash be reversed?
Not mathematically. But common inputs can be looked up: the hash of password123 appears in every precomputed table. A hash only hides inputs that are hard to guess.
Is SHA-512 better than SHA-256?
Both are secure. SHA-512 has a longer output and is faster on some 64-bit machines, but SHA-256 is the more widely used default.
Are collisions possible with SHA-256?
In theory any hash has collisions, because infinitely many inputs map to a fixed-length output. In practice, nobody has ever found one for SHA-256, and finding one is far beyond current computing power.
Last updated
October 12, 2026