JNanoId
A unique string ID generator for Java.
Secure
JNanoID uses Java’s SecureRandom to generate cryptographically strong random IDs with a proper distribution of characters.
Compact
JNanoID generates compact IDs with just 21 characters. By using a larger alphabet than UUID, JNanoID can generate a greater number of unique IDs, when compared to UUID, with fewer characters (21 versus 36).
URL-Friendly
JNanoID uses URL-friendly characters (A-Za-z0-9_-). Perfect for unique identifiers in web applications.
Customizable
JNanoID is fully customizable. All default options may be overridden. Supply your own Random Number Generator, alphabet, or size.
Tested
JNanoID is thoroughly tested with JUnit.
Latest Release
The most recent release is JNanoId 2.0.0.
Maven
<dependency>
<groupId>com.aventrix.jnanoid</groupId>
<artifactId>jnanoid</artifactId>
<version>2.0.0</version>
</dependency>
Gradle
compile 'com.aventrix.jnanoid:jnanoid:2.0.0'
Usage
JNanoId provides one easy-to-use utility class (NanoIdUtils) with two methods to generate IDs.
Standard IDs - randomNanoId()
The default method creates secure, url-friendly, unique ids. It uses a url-friendly alphabet (A-Za-z0-9_-), a secure random number generator, and generates a unique ID with 21 characters.