MD5 Collisions Explained

Two different inputs, two different .txt files, one identical MD5 hash. See a real collision and why MD5 is broken.

A hash collision is two different inputs that produce the same digest. This page shows real MD5 collisions you can check yourself: two different 128-byte inputs and two different .txt files that share an MD5 hash while their SHA-256 hashes differ. It demonstrates why MD5 is considered broken for anything security-related.

What is a collision?

A hash function is meant to give every different input its own fingerprint. A collision is when two different inputs give the same one. They always exist in theory, because there are endless possible inputs and only a fixed number of digests. For a strong hash they are impossible to find in practice. For MD5 they can be made on demand, in seconds, and the examples below are real.

Two different inputs, one MD5

These two 128-byte blocks are not text, so they are shown as hexadecimal. They are different, and the bytes that differ are highlighted. MD5 gives both of them exactly the same result.

Input A

d1 31 dd 02 c5 e6 ee c4 69 3d 9a 06 98 af f9 5c
2f ca b5 87 12 46 7e ab 40 04 58 3e b8 fb 7f 89
55 ad 34 06 09 f4 b3 02 83 e4 88 83 25 71 41 5a
08 51 25 e8 f7 cd c9 9f d9 1d bd f2 80 37 3c 5b
d8 82 3e 31 56 34 8f 5b ae 6d ac d4 36 c9 19 c6
dd 53 e2 b4 87 da 03 fd 02 39 63 06 d2 48 cd a0
e9 9f 33 42 0f 57 7e e8 ce 54 b6 70 80 a8 0d 1e
c6 98 21 bc b6 a8 83 93 96 f9 65 2b 6f f7 2a 70
MD5
79054025255fb1a26e4bc422aef54eb4
SHA-256
8d12236e5c4ed9f4e790db4d868fd5c399df267e18ff65c1107c328228cffc98

Input B

d1 31 dd 02 c5 e6 ee c4 69 3d 9a 06 98 af f9 5c
2f ca b5 07 12 46 7e ab 40 04 58 3e b8 fb 7f 89
55 ad 34 06 09 f4 b3 02 83 e4 88 83 25 f1 41 5a
08 51 25 e8 f7 cd c9 9f d9 1d bd 72 80 37 3c 5b
d8 82 3e 31 56 34 8f 5b ae 6d ac d4 36 c9 19 c6
dd 53 e2 34 87 da 03 fd 02 39 63 06 d2 48 cd a0
e9 9f 33 42 0f 57 7e e8 ce 54 b6 70 80 28 0d 1e
c6 98 21 bc b6 a8 83 93 96 f9 65 ab 6f f7 2a 70
MD5
79054025255fb1a26e4bc422aef54eb4
SHA-256
b9fef2a8fc93b05e7701e97196fda6c4fbeea25ff8e64fdfee7015eca8fa617d

Two different .txt files, one MD5

The same trick works on whole files. MD5 processes data in blocks, so once two inputs collide, anything you append to both keeps them colliding. These two files start with the colliding blocks above, followed by identical readable text. Download them and compare the checksums yourself.

collision-a.txt · 322 bytes

MD5
37c6ddf9d8d37210ef9a1f91e9a8204a
SHA-256
d03b2c1e8945445c12de80dc2e6100e8093ce10ede7347af0690e12996c734a3
Download

collision-b.txt · 322 bytes

MD5
37c6ddf9d8d37210ef9a1f91e9a8204a
SHA-256
d89eb998a17085e7ebdb637113ee9c459508f9f653134729dbd8f0fb46f46603
Download

Check it yourself

# Linux / macOS
md5sum collision-a.txt collision-b.txt
sha256sum collision-a.txt collision-b.txt

# Windows PowerShell
Get-FileHash -Algorithm MD5 collision-a.txt, collision-b.txt
Get-FileHash -Algorithm SHA256 collision-a.txt, collision-b.txt

The MD5 values match and the SHA-256 values do not. You can also drop either file into the Hash Generator.

The files will look like gibberish at the start when opened in a text editor. That is the colliding block, which is binary data, so the files are not really plain text even though they end in .txt.

What this does and doesn't show

  • Collision attack: someone makes two inputs with the same hash. This is what is shown here, and it is practical for MD5.
  • Preimage attack: someone finds an input that matches a hash they were given. This is still not practical for MD5, so an MD5 digest cannot simply be reversed.

The danger is when an attacker gets to choose the files. They can prepare a harmless version for review or signing and a malicious version with the same MD5, so a matching checksum proves nothing. This is how a forged CA certificate was built in 2008. This pair is the original from the 2004 research. Later attacks (chosen-prefix collisions) let attackers pick two different readable documents and add the collision blocks afterwards, which is far more practical to abuse.

MD5 is still fine for spotting accidental corruption or as a cache key. For anything security-related, use SHA-256 or stronger. SHA-1 has had its own practical collision since 2017 (“SHAttered”). See the Hash Generator for more on choosing an algorithm.