Hash Collision Probability Calculator
Apply the birthday bound to any digest length: collision probability at your item count and the safe volume per digest.
About Hash Collision Probability Calculator
Collisions depend on the number of pairs, which grows as k² ÷ 2, so the risk crosses 50% at roughly the square root of the digest space — 2^64 items for a 128-bit digest. Expected colliding pairs is the same ratio without the exponential, which is the more useful figure once the probability is tiny. Truncating a hash to fit a database column or a short URL is where this bites: a 64-bit fingerprint collides with even odds after only 5 billion items, which is well inside the range of a real content-addressed store.
Formulas
Hash Collision Probability
p ≈ 1 − e^(−k² ÷ 2N) with N = 2^b; for small p this is just k² ÷ 2^(b+1).
- k
- Number of distinct items hashed
- b
- Digest length in bits
- N
- 2^b, the size of the digest space
Birthday bound
50% collision point ≈ 1.1774 × √N = 1.1774 × 2^(b ÷ 2).
Worked example
With the default values below, Hash Collision Probability Calculator returns Collision Probability (log₁₀) of -20.83. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Digest lengthone of 32-bit (CRC-32), 64-bit (truncated / xxhash64), 128-bit (MD5, truncated SHA-256), 160-bit (SHA-1), 256-bit (SHA-256), 512-bit (SHA-512)
- 128-bit (MD5, truncated SHA-256)
- Distinct items hashedminimum 1 items
- 1,000,000,000 items
Results
- Collision Probability (log₁₀)−9 means about one chance in a billion.
- -20.83
- Collision Probability
- 0.000000%
- Expected Colliding Pairs
- 0.0000
- Items for a 50% Chance (log₁₀)
- 19.34
- Items at a 2⁻³² Risk Target (log₁₀)
- 14.60
- Assessment
- Safe — collision risk below 2⁻³² at 128 bits
Step by step
- 1Values used
- 2Hash Collision Probability
- 3Birthday bound
- 4Collision Probability (log₁₀)= -20.83
- 5Collision Probability= 0.000000
- 6Expected Colliding Pairs= 0.0000
- 7Items for a 50% Chance (log₁₀)= 19.34
- 8Items at a 2⁻³² Risk Target (log₁₀)= 14.60
- 9Assessment= Safe — collision risk below 2⁻³² at 128 bits
Assumptions and limits
- The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 6 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
How is Hash Collision Probability calculated?
p ≈ 1 − e^(−k² ÷ 2N) with N = 2^b; for small p this is just k² ÷ 2^(b+1). Collisions depend on the number of pairs, which grows as k² ÷ 2, so the risk crosses 50% at roughly the square root of the digest space — 2^64 items for a 128-bit digest. Expected colliding pairs is the same ratio without the exponential, which is the more useful figure once the probability is tiny.
Why does Hash Collision Probability matter?
Truncating a hash to fit a database column or a short URL is where this bites: a 64-bit fingerprint collides with even odds after only 5 billion items, which is well inside the range of a real content-addressed store.
What values do I need to enter?
This calculator takes 2 inputs: Digest length, Distinct items hashed. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.
Why is SHA-1 considered broken if the birthday bound is 2^80?
The birthday bound is the generic limit. SHA-1's internal structure allows a chosen-prefix collision at about 2^63 work, which was demonstrated in 2019 for roughly $45,000 of cloud compute. Cryptanalysis, not the birthday bound, is what retired it.
How short can a content hash safely be?
Aim for at least twice the log₂ of your maximum item count plus 32 bits of margin. For a trillion objects (2^40) that means 112 bits or more — in practice, truncate SHA-256 to 128 bits.
