We treat large hash functions like MD5 as practically unique and safe from collisions in normal use. But that’s not always the case… Here are two strings that produce the same MD5 hash
TEXTCOLLBYfGiJUETHQ4hAcKSMd5zYpgqf1YRDhkmxHkhPWptrkoyz28wnI9V0aHeAuaKnak
TEXTCOLLBYfGiJUETHQ4hEcKSMd5zYpgqf1YRDhkmxHkhPWptrkoyz28wnI9V0aHeAuaKnak
Their Hamming distance is just 1, and their MD5 hashes collide (faad49866e9498fc1719f5289e7a0269). Look at the 22nd character, it changes from A -> E.
MD5 produces a 128-bit hash, so collisions are inevitable. What’s fascinating is how easily they can be constructed.
So better to reiterate - never rely on MD5 (or similar) for security or uniqueness guarantees. Use SHA-256 or a cryptographically secure hash when it matters.
By the way, this also highlights the difference between a “low collision probability” and true “collision resistance.”