the Nim implementation of NanoID
NanoID is a tiny, secure URL-friendly unique string ID generator.
It's safe. It uses cryptographically strong random APIs that guarantees proper distribution of symbols.
And it's compact. It uses a larger alphabet than the standard UUID (A-Za-z0-9_-
), and has a similar number of unique IDs in just 21 symbols instead of 36.
nimble install nanoid
Optionally, run the test suite (after cloning this repo) using
nimble test
Uses the default alphabet set (A-Za-z0-9_-
) and a size of 21 symbols.
import nanoid
echo generate() # RKF2A0-pGhJfpm6-rSi5C
import nanoid
echo generateNonSecure() # SL8Zh8Lfw9TIRbaQI-DxB
import nanoid
let
a = "abcdef12345"
s = 10
echo generate(alphabet=a, size=10) # 15aa1d2b3a
That’s it, really.
- Async API
Bad code? New feature in mind? Open an issue. Better still, learn Nim and shoot a PR ✨
MIT © Anirudh Oppiliappan