On this page
The one-paragraph definition
MD5 is a cryptographic hash function. You give it a sequence of bytes; it gives you back a fixed 128-bit value. Every machine, every language and every implementation produces the same value for the same bytes, and changing a single bit of the input changes roughly half the bits of the output. You cannot run it backwards. There is no key, no password and no decryption step — it is a one-way fingerprint, nothing more.
The name stands for Message Digest algorithm 5. Ronald Rivest published it in 1992 as RFC 1321, as a faster replacement for MD4. It became one of the most widely deployed hash functions in software history, which is why it is still everywhere thirty years later even though it has been considered broken for cryptographic purposes since 2004.
Why 32 characters
The output is 128 bits. Hexadecimal writes four bits per character, so 128 ÷ 4 = 32 characters. That is the whole explanation.
Take the five bytes hello — no newline, no trailing space:
input hello
bytes 68 65 6c 6c 6f
output 5d41402abc4b2a76b9719d911017c592
Add one newline and the digest changes completely:
input hello\n
output b1946ac92492d2347c6235b4d2611184
There is no visible relationship between the two outputs. Flipping one bit of input flips about half of the output bits, seemingly at random. This property is called the avalanche effect, and it is what makes a hash useful as a fingerprint: a corrupted file cannot accidentally land on the same digest as the original.
What happens inside
You do not need this to use MD5, but the shape of the algorithm explains its speed and its weaknesses.
- Pad the message. A single
1bit is appended, then zeros, until the length is 64 bits short of a multiple of 512. The original length in bits is then written into those last 64 bits. - Split into 512-bit blocks. Each block becomes sixteen 32-bit words.
- Run four rounds of sixteen operations on a 128-bit state, using bitwise AND, OR, XOR, NOT, addition modulo 2³², and a fixed table of 64 constants derived from the sine function.
- Add the result back into the running state, and continue with the next block.
Everything is 32-bit arithmetic. There is no substitution box, no large lookup table and no memory-hard step, which is precisely why MD5 is fast on a CPU and extremely fast on a GPU. That speed is the reason it must never be used to store passwords — see password hashing.
The four properties that matter
| Property | What it means | MD5 status |
|---|---|---|
| Deterministic | Same input always gives the same output. | Holds |
| Preimage resistant | Given a digest, you cannot find an input that produces it faster than brute force. | Holds |
| Second-preimage resistant | Given one input, you cannot find a different input with the same digest. | Weakened |
| Collision resistant | You cannot find any two inputs with the same digest. | Broken |
The distinction between the last three is the source of most confusion about MD5. Finding a collision is easy — a few seconds on a laptop with published tooling. Finding a preimage for a specific digest you were handed is still computationally infeasible.
In practice that means: an attacker cannot take a hash and recover the file it came from, but an attacker can construct two different files that share a hash. If your security argument depends on "nobody can make two files with the same MD5", the argument fails. If it depends on "nobody can reverse this hash", the argument still holds. Details in is MD5 still safe?
What MD5 is still used for
MD5 survives because it is already wired into things that are expensive to change:
- Legacy API signatures. Payment gateways and older REST APIs sometimes specify an MD5 of a canonical parameter string. You cannot upgrade a counterparty.
- Content addressing in old systems. Some CDNs, mail servers and deduplication tools use MD5 as a cache key. The key only needs to be stable, not secure.
- Accidental corruption detection. If nobody is attacking you, MD5 catches a truncated download or a bad disk sector just as well as SHA-256, and slightly faster.
- Reproducing published checksums. If a project only published an MD5 line, comparing it is still a better signal than not checking at all.
- Non-security fingerprinting. Hash tables, deduplication, "have I seen this file before" queries.
Generating one is trivial: the MD5 generator gives you the value for any text, and the file checksum tool does the same for a file of any size.
Where MD5 fails
Three uses are simply wrong in 2026:
- Password storage. Fast, unsalted hashing is the classic mistake. Use Argon2id, scrypt or bcrypt with a per-user salt.
- Digital signatures and certificates. If a signature covers an MD5 digest, a collision lets an attacker substitute the signed content.
- Proving a download is authentic. A checksum from the same server as the file proves nothing about intent, and with MD5 it does not even prove uniqueness.
Rule of thumb. Use MD5 when something else already requires MD5. Choose SHA-256 for anything new. Never use either for passwords.