Birthday Paradox Hash Collision Calculator
Estimate hash collisions locally with numerically stable birthday-paradox math.
Hash parameters
Choose a bit length and number of records.
Examples
64-bit threshold
calculateBirthdayParadox(64, 5_056_000_000)fiftyPercentRecords ≈ 5.056e9, collisionProbability ≈ 0.50At the √(2 ln 2 × 2^64) threshold the collision chance is one half by construction.
32-bit saturation versus the 63% crossover
calculateBirthdayParadox(32, 2 ** 32).collisionProbability
calculateBirthdayParadox(32, 92682).collisionProbability> 0.999 (saturated)
≈ 0.632 (λ ≈ 1)Filling the whole 32-bit space guarantees a collision; the 1 − 1/e point sits far below it at ~92k records.
About this tool
Birthday Paradox Hasher computes the collision probability for a b-bit hash over n records with calculateBirthdayParadox (aliased as birthdayParadox), returning { bits, records, space, collisionProbability, collisionPercent, fiftyPercentRecords, fiftyPercentLog10 }. Bit sizes are clamped to 16–512 (rounded, so 1024 becomes 512 and 1 becomes 16) and record counts are sanitized (negatives and NaN become 0, Infinity becomes Number.MAX_VALUE). The hash space is 2^bits, and the 50%-collision threshold is √(2 ln 2 × space), which for 64 bits lands at ≈5.056e9 records.
Probability uses two paths: when bits < 53, n < space, and n ≥ 2, small populations (whole part ≤ 100,000) accumulate the exact log-survival sum Σ log1p(-i/space) with -expm1 for precision; everything else uses the Poisson-style approximation λ = n²/(2 × space) with probability 1 − e^(−λ) (saturating to 1 once λ > 37). Zero or one record always yields 0. A fully populated 32-bit space (2^32 records) therefore saturates to 1, while the classic ~63.2% (1 − 1/e) crossover for 32 bits sits near 92,682 records where λ ≈ 1.
Results stay finite even for extreme inputs: Infinity records map to Number.MAX_VALUE, the threshold is capped at Number.MAX_VALUE, and non-finite probabilities are coerced into [0, 1]. fiftyPercentLog10 gives the base-10 log of the threshold for axis labeling when the raw threshold exceeds readable magnitudes.
How to use this tool
Pick a hash width and population
Enter bits (clamped to 16–512) and a record count. Read collisionProbability (0–1) and collisionPercent for the headline risk.
Read the 50% threshold
Use fiftyPercentRecords (≈5.056e9 for 64-bit) as the population where a collision becomes likelier than not; fiftyPercentLog10 helps place it on log axes.
Interpret saturation correctly
Populations near or above the space size report ~1 (a full 32-bit space is >0.999). For the textbook 63% point, probe λ ≈ 1 instead — about 92,682 records at 32 bits.
Use cases
Sizing hash widths for IDs
Check whether 32, 64, or 128 bits keep the collision risk negligible at an expected record count before choosing an ID scheme.
Explaining the birthday bound
Show why collisions arrive near √(space) rather than near space — e.g. 50% at ~5.06e9 for 64-bit hashes.
Reviewing deduplication risk
Quantify the chance that two content hashes collide in a store, cache, or fingerprint index at current scale.
Common mistakes
Mistake:Expecting 2^32 records in 32 bits to give 63%.
Fix:That population overshoots λ ≈ 1 by billions: λ = n²/(2N) is astronomically large, so the probability saturates to 1. Probe ~92,682 records for the 0.632 point.
Mistake:Passing bits outside 16–512 and expecting them verbatim.
Fix:Bits are rounded and clamped, so 1024 reports bits: 512. Read the returned bits field and compare thresholds at the clamped width.
Mistake:Reading collisionProbability as a percentage.
Fix:The 0–1 fraction is collisionProbability; multiply by 100 (or read collisionPercent) before presenting it with a % sign.
Frequently asked questions
What does this tool do?
It computes the hash-collision probability for a b-bit hash over n records with calculateBirthdayParadox, reporting the clamped bits, the 2^bits space, the 0–1 probability plus percent, and the 50%-collision threshold with its base-10 log.
Why does a full 32-bit space report ~1 instead of 0.632?
2^32 records overshoot the λ = n²/(2N) ≈ 1 crossover by billions, so the probability saturates past 0.999. The textbook 1 − 1/e ≈ 0.632 point sits far below it at ~92,682 records; zero or one record always reports exactly 0.
Is my data uploaded or stored?
No. The exact log-survival sum and the Poisson approximation are pure client-side math — bits and record counts never leave your device.
Where is the 50% threshold, and what bit widths are allowed?
The threshold is √(2 ln 2 × space), about 5.056e9 records for 64-bit hashes. Bit widths are rounded and clamped to 16–512, so 1024 reports bits: 512 — always read the returned bits field.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML