Skip to main content

Birthday Paradox Calculator

How many random values does it take until two of them probably match? Intuitively, most people estimate this number far too high.

With this calculator, you choose the size of a range of values and the number of attempts, and you immediately see how likely at least one collision is.

Birthday Collision Simulator

Choose the size of the hash space and the number of generated hash values – the probability of a hash collision is calculated exactly and instantly.

Hash space (output length)
Collision probability: 53.3%
Output length
8 bits
Possible hash values
28 = 256
Generated hash values
20
Possible pairs k(k−1)/2
190
Exact probability
53.3%
Approximation 1 − e^(−k(k−1)/(2N))
≈ 52.4%
Birthday bound (order of magnitude)
24 ≈ 16
50% threshold √(2·N·ln 2)
≈ 18.8 (exactly from 20)

The exact probability follows from P(no collision) = N/N × (N−1)/N × … × (N−k+1)/N. The approximation is only an estimate. 2n/2 describes the order of magnitude at which collisions become likely – not an exact 50% limit.

Takeaway: What matters is not the number of hash values but the number of pairs. It grows quadratically – that is why roughly √N attempts are enough for a realistic chance of a hash collision.

What Does the Experiment Show?​

The collision probability grows surprisingly fast. What matters is not the number of values but the number of possible pairs – and that grows roughly quadratically with the number of attempts.

In the well-known birthday example with 23 people and 365 equally likely birthdays, the probability that at least two people share a birthday is already roughly 50.7 percent.

If you switch to a hash space of n bits, the same effect shows up: after roughly 2^(n/2) hash values, a collision becomes realistic – far before 2^n.

More About the Birthday Paradox​

I explain the derivation and the connection with hash functions in the article The Birthday Paradox. Why this effect limits the collision security of a hash is described in What Is Collision Resistance?.

You can try out how a collision is actually found in a reduced hash space with the Birthday Attack Simulator.