diff --git a/CHANGELOG/CHANGELOG-1.x.md b/CHANGELOG/CHANGELOG-1.x.md index 28fe23e..059b06f 100644 --- a/CHANGELOG/CHANGELOG-1.x.md +++ b/CHANGELOG/CHANGELOG-1.x.md @@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed -- **DEBT:** Check for duplicate characters using a bitmask with multiple `uint32`s. A `uint32` array can represent `256` bits (`32` bits per `uint32 × 8 = 256`). This allows us to track each possible byte value without the limitations of a single uint64 ### Deprecated ### Removed ### Fixed @@ -20,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.6.0] - 2024-OCT-29 ### Added +- **FEATURE:** Added [Nano ID collision calculator](../docs/nanoid-collision-calculator.html). ### Changed - **DEBT:** Check for duplicate characters using a bitmask with multiple `uint32`s. A `uint32` array can represent `256` bits (`32` bits per `uint32 × 8 = 256`). This allows us to track each possible byte value without the limitations of a single uint64 ### Deprecated diff --git a/docs/nanoid-collision-calculator.html b/docs/nanoid-collision-calculator.html new file mode 100644 index 0000000..fe6778b --- /dev/null +++ b/docs/nanoid-collision-calculator.html @@ -0,0 +1,359 @@ + + +
+ +n = √(-2 × N × ln(1 - P))
+ n
= Total number of IDs needed to reach the target probability.N = ak
= Total number of possible unique IDs, where a
is the alphabet size and k
is the ID length.P
= Target collision probability (in this case, 0.01
for 1%).ln
= Natural logarithm.n
, and subsequently determine the time required based on the rate of ID generation.
+ 64
characters and an ID length of 21
, the total number of possible unique IDs N
is:
+ N = 6421 ≈ 1.20892582 × 1038
+ 1%
collision probability:
+ n = √(-2 × 1.20892582 × 1038 × ln(0.99)) ≈ 1.555 × 1018
+ 1,000
IDs per hour, the time t
required is:
+ t = n / rate = 1.555 × 1018 / 1,000 = 1.555 × 1015 hours ≈ 176,136,364 Years
+