๐ŸŽ‚ The Birthday Paradox: Math Behind Collisions

Learn why finding collisions is easier than you thinkโ€”but still impossibly hard

โ†
Previous
Introduction

๐ŸŽ‚ The Birthday Paradox

Here's a counterintuitive fact: In a room of just 23 people, there's a 50% chance that two share the same birthday! This paradox explains why hash collisions are easier to find than you might think.

๐Ÿค” The Classic Birthday Problem

Most people assume you'd need 183 people (half of 365 days) for a 50% collision chance. But mathematics tells a different story!

Why It's Counterintuitive:
โ€ข
Pairwise Comparisons: With 23 people, there are 253 pairs to compare (23ร—22/2)
โ€ข
Exponential Growth: Each new person compares with all previous people, creating many opportunities for a match
โ€ข
Any Match Counts: We don't care WHICH two people match, just that ANY match exists

๐ŸŽฎ Interactive Birthday Simulator

Adjust the number of people and see how collision probability changes:

23
550100
Collision Probability
50.7%

๐Ÿ”ข Key Birthday Probabilities

๐Ÿ‘ฅ
23 people
Classic threshold
50.7%
๐Ÿ‘ฅ๐Ÿ‘ฅ
50 people
High confidence
97%
๐Ÿ‘ฅ๐Ÿ‘ฅ๐Ÿ‘ฅ
70 people
Near certainty
99.9%

๐Ÿ” Applying to Hash Functions

The birthday paradox explains why finding hash collisions is easier than brute-forcing a specific hash. Instead of targeting ONE hash, attackers can generate MANY inputs and look for ANY collision.

The Math:
Hash output space: 2^n possible outputs
Brute force attack: ~2^n attempts needed
Birthday attack: ~2^(n/2) attempts needed โœ“
โšก Birthday attacks are exponentially faster!
Hash Size Comparison:
Hash SizePossible OutputsCollision at ~Example
8 bits256~16Tiny hash
16 bits65K~256Very weak
32 bits4.3B~65KCRC32
128 bits3.4ร—10ยณโธ~2โถโดMD5 (broken)
256 bits1.2ร—10โทโท~2ยนยฒโธSHA-256 (secure)

๐Ÿ’ก Key Insights

๐ŸŽฏ
Square Root Rule

For n-bit hash, collisions appear after ~2^(n/2) attempts. SHA-256 (256 bits) requires ~2^128 attempts for collision.

โšก
Why Bigger is Better

Doubling hash size from 128 to 256 bits increases collision resistance from 2^64 to 2^128 - that's 18 quintillion times harder!

๐Ÿ”’
SHA-256 Security

With 2^128 attempts needed and billions of hashes per second, finding a SHA-256 collision would take longer than the age of the universe.