#unique-id #id-generator #id #random #uuid #url

nano-id

A tiny, secure, URL-friendly, unique string ID generator for Rust

9 releases

0.3.3 Nov 19, 2023
0.3.1 Mar 28, 2023
0.3.0 Jul 11, 2022
0.2.0 Oct 1, 2021
0.1.1 Jun 17, 2021

#9 in #id-generator

Download history 70/week @ 2023-12-24 287/week @ 2023-12-31 56/week @ 2024-01-07 6/week @ 2024-01-14 14/week @ 2024-01-28 26/week @ 2024-02-04 46/week @ 2024-02-11 21/week @ 2024-02-18 41/week @ 2024-02-25 45/week @ 2024-03-03 22/week @ 2024-03-10 54/week @ 2024-03-17 12/week @ 2024-03-24 39/week @ 2024-03-31 1/week @ 2024-04-07

108 downloads per month
Used in 3 crates

MIT/Apache

8KB
75 lines

nano-id

A tiny, secure, URL-friendly, unique string ID generator for Rust

Inspired by nanoid

Features

  • Base58: ModueSymbhaswnPr123456789ABCDEFGHNRVfgctiUvzKqYTJkLxpZXjQW, (123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz)
  • Base62: ModuleSymbhasOwnPr0123456789ABCDEFGHNRVfgctiUvzKqYTJkLxpZXIjQW, (A-Za-z0-9)
  • Base64: ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW, (A-Za-z0-9_-)
  • Random: data by getrandom
  • Alphabet: custom with gen!(uid, 64, b"_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

Installation

cargo add nano-id

Usage

nano_id::base64::<21>();

// Custom ALPHABET
nano_id::gen!(
    uid,
    64,
    b"_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
);

uid::<21>();

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~54–465KB