Hash collision probability calculator
Collisions become likely at roughly the square root of the space, not at the space itself. That is the birthday paradox, and it halves your effective bits.
Collision probability
1.46937e-13%
- One in how many
- 680 565 000 000 000
- Items for a 50% chance
- 2.17194e+19
- Square root of the space
- 1.84467e+19
- Effective collision resistance
- 64.0 bits
- Size of the hash space
- 3.40282e+38
Show the working
- Hash size = 128
- Number of items = 1 000 000 000 000
- Size of the hash space = 2^128 = 3.40282e+38
- exponent = 1 000 000 000 000 * (1 000 000 000 000 - 1) / (2 * 3.40282e+38) = 1.46937e-15
- Collision probability = 1.46937e-15 < 1e-12 ? 1.46937e-15 * 100 : (1 - exp(-1.46937e-15)) * 100 = 1.46937e-13
- Square root of the space = sqrt(3.40282e+38) = 1.84467e+19
- Items for a 50% chance = 1.1774100225154747 * sqrt(3.40282e+38) = 2.17194e+19
- Effective collision resistance = 128 / 2 = 64
- One in how many = 1.46937e-13 > 0 ? 100 / 1.46937e-13 : 0 = 680 565 000 000 000
Values are shown to six significant figures here; the arithmetic itself runs on exact fractions and is only rounded where a number is printed.
Scenarios & local history
Compare a saved scenario
Recent calculations
The formula
- P(collision) is about 1 - exp(-n(n-1) / 2N) for n items in a space of N
- a 50% chance arrives at about 1.1774 sqrt(N) items
A 128-bit hash has 64 bits of collision resistance, which is why 256-bit hashes are the modern default.
Random UUID version 4 has 122 random bits; a trillion of them collide with probability around 1 in 10 million.