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

nano-id

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

10 releases

0.4.0 Jun 2, 2024
0.3.3 Nov 19, 2023
0.3.2 Sep 15, 2023
0.3.1 Mar 28, 2023
0.1.1 Jun 17, 2021

#1287 in Web programming

Download history 89/week @ 2024-07-22 104/week @ 2024-07-29 56/week @ 2024-08-05 51/week @ 2024-08-12 74/week @ 2024-08-19 54/week @ 2024-08-26 36/week @ 2024-09-02 33/week @ 2024-09-09 36/week @ 2024-09-16 150/week @ 2024-09-23 107/week @ 2024-09-30 74/week @ 2024-10-07 43/week @ 2024-10-14 45/week @ 2024-10-21 39/week @ 2024-10-28 39/week @ 2024-11-04

171 downloads per month
Used in 3 crates

MIT/Apache

8KB
100 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

~51–455KB