# **rs-nanoid** Nano ID logo by Anton Lovchikov [This crate](https://crates.io/rs-nanoid) is the most efficient implementation of [ai/nanoid](https://github.com/ai/nanoid). **https://crates.io/rs-nanoid** Features of the Nano ID spec are: - URL friendly - Use of cryptographic random generator - Uses a bigger alphabet than UUID, so a similar number of random bits are packed in just 21 chars instead of 36 (like UUID) - Much, much faster than UUID (v4) Features of this specific implementation are: - Fastest and most performant implementation of Nano ID around ([benchmarks](#benchmarks)) - Minimal memory usage. - Fully optimized (`nanoid::standard` and `nanoid::standard_unsecure`). **Docs and examples at https://docs.rs/rs-nanoid**. ## Install Add to `Cargo.toml` under `[dependencies]`. ``` rs-nanoid = "0.1.0" ``` # Security **[NanoID collision calculator](https://zelark.github.io/nano-id-cc/)**: > If 1,000,000 Nano IDs of length 21 (a.k.a. `nanoid::standard::<21>`) were generated **each second**, ~41 thousand years would be required in order to have a 1.0% probability of a collision. **[Comparison of Nano ID and UUID (V4)](https://github.com/ai/nanoid/blob/main/README.md#comparison-with-uuid)**. **[More here](https://github.com/ai/nanoid/blob/main/README.md)**. ## Benchmarks Tests are inside of `lib.rs` and benchmarks are in the `benches` folder. These are benchmarks of `nanoid::standard::()`. | OS | ARCH | CPU | | ---------- | ----- | ---------------------- | | Windows 10 | amd64 | Core i7-7500U @ 2.7GHz | | length | sample pool | graph (sample of 100 from pool) | |:------ |:------------ | --------------------------------- | | 8 | ~254,200,000 | | | 21 | ~124,000,000 | | | 36 | ~86,300,000 | | | 255 | ~18,200,000 | | ## References - [Original (JavaScript) reference](https://github.com/ai/nanoid) ## License [GNU General Public License v3.0](./LICENSE)