MD5 and why it is broken
MD5 gives every input a 128-bit fingerprint. See what that was used for, how two inputs came to share one fingerprint, and why that ended its use in security.
In 30 seconds
MD5 turns any data into a short 128-bit fingerprint, or hash. It was used to check downloads, store passwords and make digital signatures.
A hash is only safe if nobody can find two different inputs with the same fingerprint, a collision. For MD5 that now takes seconds, so a signature on one document can be moved to another.
For security, use SHA-256 or SHA-3, and a slow password function such as Argon2. MD5 is still fine for spotting accidental damage, where no one is trying to cheat.
MD5 and why it is broken, step by step
Only collision resistance is broken. Nobody can yet take an MD5 hash and find an input that produces it (a preimage), but MD5 is retired from security use all the same.
- Step 1: A 128-bit fingerprint. MD5 is a hash function from 1991. It boils any input, a word or a whole film, down to 128 bits, written as 32 hex digits. The same input always gives the same result, and changing one letter gives a result with nothing in common.
- Step 2: What it was used for. For years MD5 was everywhere: as a checksum beside downloads, as the stored form of passwords, and inside digital signatures, where the signer signs the short hash instead of the whole document or certificate. All three lean on one promise about the hash.
- Step 3: The promise: no collisions. A collision is two different inputs with the same hash. Collisions must exist, because there are endless inputs and only a fixed number of 128-bit outputs. The promise is that finding one is out of reach: for a sound 128-bit hash it takes about 2⁶⁴ attempts.
- Step 4: Broken in practice. In 2004 Xiaoyun Wang and colleagues showed how to steer MD5 into a collision with far less work than promised. By 2006 it took under a minute on a laptop. These two real 128-byte inputs differ in six bytes and share one MD5 hash.
- Step 5: Why it breaks signatures. A signature covers the hash, not the document. Someone who prepares two colliding documents can have the harmless one signed, then attach that signature to the other, and it verifies. Researchers forged a certificate authority this way in 2008, and the Flame malware used the same trick in 2012.
- Step 6: What to use instead. For fingerprints, signatures and certificates, use a hash with no known collisions, such as SHA-256 or SHA-3. Passwords need a different tool altogether: a deliberately slow, salted function such as Argon2, bcrypt or PBKDF2, because any fast hash can be guessed against billions of times a second.
- Step 7: Where MD5 is still harmless. MD5 still spots accidental damage perfectly well: a flipped bit or a cut-off download changes the hash. So it survives as a checksum, cache key or de-duplication label where nobody is trying to cheat. It gives no protection once someone can craft the data.
Try it yourself
Learn this first
Nothing. This concept starts from scratch.
Learn next
- SHA-256 hashingHow any message becomes a fixed 256-bit fingerprint. Intermediate
- Digital certificates and certificate authoritiesHow a signed file and a chain of authorities tie a public key to a name. Intermediate
- Rainbow tablesTrading memory for time to reverse password hashes, and why a salt ruins the trade. Intermediate
Spotted a mistake on this page?