Skip to content

Entropy

Caleb Ephrem edited this page Sep 20, 2025 · 1 revision

πŸͺ£ Entropy Space of UCID

If you use the default options, even if you generate 1 billion IDs per second, you'd need hundreds of millions of years to have a meaningful chance of a collision. Sounds unbelievable? Let’s do the math:

Collision Probability of Secure Random 32-Character ID (Base36)

ID Format: xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx
Character Set: 36 characters (0–9, a–z)
Length: 32 characters
Randomness Source: Cryptographically secure (crypto.randomBytes)

Total Possible Unique IDs

36^32 β‰ˆ 6.334 Γ— 10^49

Generation Rate

  • IDs per second: 1,000,000,000
  • Seconds per year: 60 Γ— 60 Γ— 24 Γ— 365 = 31,536,000
  • IDs per year: 1 Γ— 10^9 Γ— 31,536,000 = 3.1536 Γ— 10^16

Collision Threshold (Birthday Paradox)

√(36^32) = 36^16 β‰ˆ 7.961 Γ— 10^24

Years to Reach 50% Collision Probability

7.961 Γ— 10^24 Γ· 3.1536 Γ— 10^16 β‰ˆ 252,443,706 years

βœ… Conclusion

Using cryptographically secure randomness, your custom 32-character base36 ID format would take ~252 million years of generating 1 billion IDs per second to reach a 50% chance of collision.

This makes it extremely safe for any real-world application. Offers greater collision resistance than UUID v4 (~82 thousand years of generating 1 billion IDs per second) thanks to a larger entropy space (6.334 Γ— 10^49), powered by cryptographically secure randomness.

Clone this wiki locally