mrdimidium / nanoid

A tiny, secure, URL-friendly, unique string ID generator for Rust
https://docs.rs/nanoid
MIT License
545 stars 29 forks source link

Unique String ? #23

Closed NelDav closed 3 years ago

NelDav commented 3 years ago

In your description, you talk about a unique string ID. But I cannot find any code which guarantees that the string is unique.

Am I misunderstanding the description or am I missing the relevant code? If there is no guarantee that the string is unique, maybe the word unique in the description should be removed.

mrdimidium commented 3 years ago

Hey.

The point is that with the alphabet and default length (21 char), it will take ~ 149 billion years to have a 1% probability of at least one collision. This can be considered a unique string.

More about: Birthday problem, Collisions

NelDav commented 3 years ago

Thank you very much. I only want to be sure if I missed something in the code. I need to be sure that the strings are unique. Because that I wrapped nanoid to checks if any string already appeared before.

/close