Important
Read the full documentation on the iNKraft website.
https://datlag.dev/libraries/nanoid/
A Kotlin Multiplatform port of this JavaScript library, providing a fast, secure and URL-friendly unique ID generator.
The following targets are supported:
| Platform | Targets |
|---|---|
| JVM & Android | jvm, android |
| Apple | ios, macos, tvos, watchos |
| Web | js, wasmJs |
| Native & Other | linux, mingw |
NanoId comes with several features while beeing fully customizable.
NanoId uses Korlibs Crypto SecureRandom to generate cryptographically strong random IDs with a proper distribution of characters.
Crypto provides a SecureRandom class that extends the kotlin.random.Random class, but generating cryptographic secure values.
- It uses
SecureRandomon the JVM +PRNGFixeson Android. - On Native POSIX (including Linux, macOS, iOS) it uses
/dev/urandom - On Windows
BCryptGenRandomis in use
NanoId generates compact IDs with just 21 characters.
By using a larger alphabet than UUID, NanoId can generate a greater number of unique IDs, when compared to UUID, with fewer characters (21 vs 36).
NanoId is fully customizable.
All default options may be overridden. Supply your own Random Number Generator, alphabet or size.