Audited ·Last updated 28 Jul 2026·6 citations·Tier 2·0 uses

Hash Collision Probability Calculator

Work out the chance that two of N values share a hash, for CRC-32, 64-bit digests, UUIDv4, MD5, SHA-1, SHA-256, SHA-512 or any custom width.

Hash Collision Probability Calculator

Digest
Only used when the digest above is set to Custom. If you truncate a longer hash, enter the truncated width — that is the width that governs collisions.
Every value that goes into the same space and could collide with any other. For a database key, this is the total number of rows you expect over the system's whole life, not the number live today.
Probability of at least one collision
0.0267
P(at least two of the values share a digest), between 0 and 1, computed as 1 − e^(−λ). Rounded to 12 significant digits because the value routinely runs below 10⁻¹⁰⁰.
Same figure as a percentage
2.67
Expected colliding pairs
0.0271
Random bits in the digest
64 bits
Collision resistance
32 bits
50 % point (power of 10)
9
What this means
About a 2.67 % chance of at least one collision — roughly 1 in 37.4. That is 1000000000 values hashed into a 64-bit digest, a space of 2^64 digests. The figure assumes the digests are spread uniformly and independently, and it counts only accidental collisions — it says nothing about an attacker deliberately constructing two inputs with the same digest, which for MD5 and SHA-1 costs far less than this arithmetic suggests.

Background.

Hash two different values and you can, with bad luck, get the same digest back. This calculator works out how likely that is: give it a digest width and a number of values, and it returns the probability that at least two of them collide, the expected number of colliding pairs, and the point at which a collision becomes more likely than not.

It is the birthday problem with a bigger room. Twenty-three people give a better-than-even chance of a shared birthday because what matters is the number of pairs, not the number of people, and pairs grow as the square of the group. The same square shows up here: the expected number of colliding pairs among k values in a space of N digests is k(k−1)/(2N), and the probability of at least one is 1 − e^(−λ) where λ is that expectation. Setting that to a half gives the familiar birthday bound, √(2N ln 2) ≈ 1.1774 × 2^(n/2) — which is exactly why NIST SP 800-107 Rev. 1 states that an L-bit hash function has a collision resistance of L/2 bits, and why RFC 4270 puts the attacker's cost at 2^(L/2) attempts rather than 2^L.

The practical lesson lands hardest at the small end. A hundred thousand values in a 32-bit CRC space collide 68.8 % of the time, which is why CRC-32 is an error-detection checksum and not an identifier. A billion values in a 64-bit space collide about 2.7 % of the time — small, but not small enough to bet a primary key on, and 5.06 billion values in that space is a coin flip. Move to 128 bits and a trillion values give a probability around 1.5 × 10⁻¹⁵; move to SHA-256 and the numbers stop being meaningful in any physical sense.

One detail is worth getting right because almost everybody gets it wrong: a version 4 UUID is 128 bits long but only 122 of them are random. RFC 9562 specifies four bits for the version and two for the variant, so the usable space is 2¹²², not 2¹²⁸. Calculating with 128 understates the collision probability by a factor of 64. This calculator uses 122 for the UUID option and says so.

What the page models is an accidental collision between digests assumed to be uniformly and independently distributed — the case that matters when you are sizing a key, a shard identifier, a deduplication index or a short link. It does not model a deliberate collision constructed by an attacker. That is a different and much cheaper problem for a broken function: RFC 4270 records that every practical attack on MD5 and SHA-1 is a collision attack, and both fell far below their birthday bounds. If your threat model includes somebody who wants two colliding inputs, the number on this page is not the number you need.

Below the widget you will find the derivation from the exact product formula, a worked example computing the 64-bit case by hand, the reason the calculator switches between three different numerical methods depending on the size of λ, and guidance on which digest width to pick for a given number of values.

What is hash collision probability calculator?

A hash collision is two different inputs producing the same digest. Because a hash function maps an unlimited set of inputs onto a fixed-size output, collisions must exist; the only question is how likely you are to meet one. If the function spreads its outputs uniformly — which a good cryptographic hash approximates well — then hashing k values into a space of N = 2ⁿ digests is a balls-into-bins problem, and the answer is governed by the number of pairs rather than the number of values. There are k(k−1)/2 pairs, each of which collides with probability 1/N, so the expected number of colliding pairs is λ = k(k−1)/(2N), and the probability that at least one pair collides is very close to 1 − e^(−λ). This grows far faster than intuition suggests: the number of values needed for an even chance is around the square root of the space, not half of it. That square root is the birthday bound, and it is the reason NIST measures a hash function's collision resistance at half its output length — SHA-256 produces 256 bits and offers 128 bits of collision resistance. Two things fall outside this model. First, it assumes uniformity: a hash function with structural bias, or a non-cryptographic function fed adversarially chosen keys, collides more often than the arithmetic says. Second, it counts only accidental collisions. An attacker who wants two inputs with matching digests attacks the function itself, and against MD5 or SHA-1 that costs vastly less than the birthday bound implies.

How to use this calculator.

  1. Choose the digest. If you are truncating a longer hash — storing the first 8 bytes of a SHA-256, for example — pick Custom and enter the truncated width, because the truncated width is what governs collisions.
  2. For UUIDs, use the UUID version 4 option. It uses 122 bits, not 128, because six bits of a UUIDv4 are fixed by the specification.
  3. Enter the number of values that share the space. For a database key this is the total you expect over the entire life of the system, including deleted rows if their identifiers are never reused — not the number live at any one moment.
  4. Read the probability first, then the expected colliding pairs beside it. When that expectation is well below 1 the two numbers are nearly identical; when it climbs past about 40 a collision is a certainty and the probability pins at 1.
  5. Use the 50 % point to size a future space. It is reported as a power of ten, so a value of 9 means a collision becomes more likely than not somewhere around a billion values.
  6. Remember what the number does not cover: an attacker deliberately constructing a collision. For that, the relevant figure is the published attack cost against the specific function, which for MD5 and SHA-1 is far below the birthday bound.

The formula.

λ = k(k−1) ÷ (2N) p = 1 − e^(−λ) k₅₀ = √(2N ln 2)

The exact probability of no collision among k values is the product (1 − 1/N)(1 − 2/N)…(1 − (k−1)/N): the second value must miss the first, the third must miss both, and so on. That product is exact and completely impractical — nobody is multiplying a billion terms. Applying the inequality 1 − u ≤ e^(−u) to each factor collapses it: the product is at most exp(−(1 + 2 + … + (k−1))/N) = exp(−k(k−1)/(2N)). Writing λ for that exponent gives p ≈ 1 − e^(−λ). Because the inequality runs one way, the result is a lower bound on the true probability, and the gap is invisible whenever k is much smaller than N.

λ has a meaning worth keeping in view: it is the expected number of colliding pairs, C(k,2)/N. There are k(k−1)/2 pairs, and each collides with probability 1/N. When λ is well below 1 the probability is essentially λ itself, which is why a tiny expectation and a tiny probability report the same number. When λ climbs past 40, e^(−λ) is smaller than 10⁻¹⁷ and the probability is 1 for any practical purpose.

Setting 1 − e^(−λ) = 0.5 gives λ = ln 2, and solving for k gives k₅₀ = √(2N ln 2) = 1.1774… × 2^(n/2). That constant of 1.1774 is why the birthday bound is usually quoted simply as 2^(n/2): the two differ by less than 18 %, which is nothing next to an exponential. NIST SP 800-107 Rev. 1 states the same fact as a security property — for an L-bit hash function the expected security strength for collision resistance is L/2 bits — and extends it to truncation: truncating an L-bit digest to λ bits reduces its collision resistance to λ/2 bits.

The implementation switches between three methods because no single expression survives the whole range. Above λ = 40 it returns 1 outright. Below λ = 0.001 it uses the Maclaurin series λ − λ²/2 + λ³/6 − λ⁴/24, because evaluating 1 − e^(−λ) directly there subtracts two numbers that agree to twenty digits and returns zero for probabilities that are genuinely 10⁻²⁰ or 10⁻²⁰⁰. In between it evaluates 1 − e^(−λ) in arbitrary precision, where the expression is well conditioned. The probability outputs are rounded to 12 significant digits rather than to a fixed decimal place, for the same reason.

A worked example.

Example

A service is about to use a 64-bit digest as a primary key and expects to generate a billion of them. The space is N = 2⁶⁴ = 18,446,744,073,709,551,616, so 2N = 36,893,488,147,419,103,232. The number of pairs is k(k−1)/2, and k(k−1) = 1,000,000,000 × 999,999,999 = 999,999,999,000,000,000. Dividing gives λ = 999,999,999,000,000,000 ÷ 36,893,488,147,419,103,232 = 0.027105054285 expected colliding pairs. Since λ is comfortably above the series threshold, the probability comes from the exponential: e^(−0.027105054285) = 0.973258991…, so p = 1 − 0.973258991 = 0.026741008874. That is 2.6741008874 %, or roughly a 1 in 37.4 chance — meaningfully likely, and not something to discover in production. The 50 % point confirms how close to the edge this is: √(2 × 2⁶⁴ × ln 2) = 1.1774100226 × 2³² = 5,056,937,540.7, reported as a power of ten of 9. Five billion values in a 64-bit space is a coin flip, and this system is planning a billion. NIST SP 800-107 Rev. 1 puts the same fact as a security property — a 64-bit digest carries 32 bits of collision resistance. Switching the digest to 128 bits drops the probability for the same billion values to about 1.5 × 10⁻²¹; switching to a version 4 UUID, with its 122 random bits, gives 9.40 × 10⁻²⁰. Either is a decision you can stop thinking about.

hash Functionbits64
custom Bits64
item Count1,000,000,000

Frequently asked questions.

Is a UUIDv4 collision really possible?
Possible, yes; worth planning for, almost never. A UUIDv4 carries 122 random bits, because RFC 9562 fixes four bits for the version and two for the variant. Generating a billion of them gives a collision probability of about 9.4 × 10⁻²⁰ — roughly one in 10¹⁹. You would need around 2.7 × 10¹⁸ UUIDs before reaching a 50 % chance. The realistic failure mode is not the mathematics, it is the generator: a UUIDv4 built from a weak or badly seeded random source, or from a PRNG reset to the same state on two machines, collides at rates that have nothing to do with 2¹²². RFC 9562's own section on collision resistance tells implementers to judge the consequences per use case for exactly this reason.
Why does the calculator use 122 bits for UUIDv4 instead of 128?
Because only 122 of the 128 bits vary. RFC 9562 §5.4 describes generating "the exact required number of bits for random_a, random_b, and random_c (122 bits total)"; the remaining six bits are the version nibble and the variant bits, and they are identical in every UUIDv4 ever made. Two UUIDs that agree on all 122 random bits are the same UUID. Using 2¹²⁸ in the denominator makes the probability 64 times smaller than it really is — not a difference that changes a decision at these scales, but wrong is wrong, and this is the single most common error in UUID collision estimates.
How many values can I put in a 64-bit hash space?
Depends entirely on the probability you are willing to accept, and the answer is smaller than most people guess. Ten million values give about a 0.0000271 % chance. A hundred million give 0.0271 %. A billion give 2.67 %. Five billion is a coin flip. If a collision would silently corrupt data, 64 bits is a poor choice for anything above the low millions; if a collision merely causes a retry, it may be fine at a billion. The general rule is that the interesting scale is the square root of the space — 2³² ≈ 4.3 billion for a 64-bit digest — and you want to stay several orders of magnitude below it.
MD5 is broken. Does that change the collision probability here?
Not this probability, but it changes whether this probability is the right question. The figure on this page is for an accidental collision between digests that happen to land on the same value, and by that measure MD5's 128 bits behave much like any other 128-bit digest. What is broken about MD5 is deliberate collisions: RFC 4270 records that every practical or near-practical attack on MD5 and SHA-1 is a collision attack, and constructing two colliding MD5 inputs is now trivial rather than costing the 2⁶⁴ operations the birthday bound suggests. So MD5 is still acceptable as a non-adversarial checksum and completely unacceptable anywhere an attacker chooses the input.
What does 'collision resistance in bits' mean?
It is the base-2 logarithm of the work needed to find a collision, and for a hash function it is half the output length. NIST SP 800-107 Rev. 1 puts it plainly: for an L-bit hash function, the expected security strength for collision resistance is L/2 bits, so SHA-256's 256-bit output provides 128 bits of collision resistance. RFC 4270 states the same bound from the attacker's side — finding two messages with the same hash takes 2^(L/2) attempts. That halving is a direct consequence of the birthday effect, and it is why a 128-bit digest gives only 64 bits of collision resistance while giving 128 bits against preimage attacks.
Does truncating a hash matter?
Enormously, and it is the reason the calculator offers a custom width. NIST SP 800-107 Rev. 1 §5.2.2 states that when an L-bit hash function's output is truncated to λ bits, the collision resistance falls to λ/2 bits. Storing the first 8 bytes of a SHA-256 gives you a 64-bit digest with 32 bits of collision resistance — SHA-256's strength is irrelevant once you throw away three-quarters of it. If you truncate, enter the truncated width here, not the original.
Why does the probability sometimes equal the expected number of colliding pairs exactly?
Because when collisions are rare the two quantities converge. The probability of at least one collision is 1 − e^(−λ), and for small λ that expands to λ − λ²/2 + λ³/6 − …, so the difference between the probability and λ itself is on the order of λ²/2. At λ = 10⁻³⁸ that difference is 10⁻⁷⁶, far below the twelve significant digits reported, so the two outputs print identically. The gap only becomes visible once λ approaches 1 — at λ = 0.5, for instance, the expected pair count is 0.5 but the probability is 0.393.
Why is the answer capped at 1024 bits and 10⁴⁰ values?
Because past those bounds the model stops telling you anything. 1024 bits is twice the widest hash NIST currently approves, and any digest that wide gives a collision probability indistinguishable from zero for any number of values a computer could produce. 10⁴⁰ values is far beyond anything physically storable — for scale, SHA-256's 50 % point sits at about 4 × 10³⁸ values. The limits also keep the arithmetic honest, since the arbitrary-precision key space stays a calculation rather than an unbounded one.

References& sources.

  1. [1]NIST SP 800-107 Revision 1, 'Recommendation for Applications Using Approved Hash Algorithms', §4, §4.1 and §5.2.2. Source of the collision-resistance rule used here, quoted verbatim: 'The expected collision-resistance strength of a hash function is half the length of the hash value produced by that hash function, i.e., for an L-bit hash function, the expected security strength for collision resistance is L/2 bits. For example, SHA-256 produces a (full-length) hash value of 256 bits; SHA-256 provides an expected collision resistance of 128 bits.' §5.2.2 extends the rule to truncated digests: truncating an L-bit output to λ bits reduces collision resistance to λ/2 bits. §4 also lists the FIPS 180-4 output lengths used for the SHA-1, SHA-256 and SHA-512 options (160, 256 and 512 bits).
  2. [2]IETF RFC 4270, 'Attacks on Cryptographic Hashes in Internet Protocols', §2 and §2.1. Source of the birthday bound stated from the attacker's side — 'Finding a pair of messages M1 and M2 that have the same hash value takes 2^(L/2) attempts' — and of the distinction this page draws between accidental and deliberate collisions: 'All the currently known practical or almost-practical attacks on MD5 and SHA-1 are collision attacks.'
  3. [3]IETF RFC 9562, 'Universally Unique IDentifiers (UUIDs)', §5.4 and §6.7. Source of the 122-bit figure used for the UUIDv4 option: an implementation 'MAY choose to randomly generate the exact required number of bits for random_a, random_b, and random_c (122 bits total)'. §6.7 'Collision Resistance' instructs implementers to evaluate the consequences of a collision for their own use case.
  4. [4]IETF RFC 1321, 'The MD5 Message-Digest Algorithm', §1. Source of the 128-bit width used for the MD5 option: the algorithm 'takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input'.
  5. [5]NIST, Computer Security Resource Center Glossary — 'collision resistance'. 'An expected property of a cryptographic hash function whereby it is computationally infeasible to find a collision', sourced by NIST to SP 800-106 and SP 800-107 Rev. 1.
  6. [6]NIST, Computer Security Resource Center Glossary — 'security strength'. 'A number associated with the amount of work (i.e., the number of operations) that is required to break a cryptographic algorithm', measured in bits, with roughly 2^S operations required at strength S. Used to relate the collision-resistance bits reported here to an attacker's workload.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 590 calculators remain free
  • No billing is enabled
Coming soon