Awesome
CUID for Java
Java implementation of CUID. Read more at <a href="https://usecuid.org/">CUID official website</a>.
Build
To compile CUID for Java, you must ensure that Java 11 (or above) and Maven are correctly installed.
#> mvn package
#> mvn install
To speed up process, you can ignore unit tests by using: -DskipTests=true -Dmaven.test.skip=true
.
How to use
<dependency>
<groupId>io.github.thibaultmeyer</groupId>
<artifactId>cuid</artifactId>
<version>x.y.z</version>
</dependency>
final CUID cuid = CUID.randomCUID1();
System.out.println("CUID: " + cuid);
final CUID cuid = CUID.randomCUID2();
System.out.println("CUID (Version 2): " + cuid);
final int customLength = 8; // Length must be, at least, 1
final CUID cuid = CUID.randomCUID2(customLength);
System.out.println("CUID (Version 2): " + cuid);
final CUID cuid = CUID.fromString("cl9gts1kw00393647w1z4v2tc");
System.out.println("CUID: " + cuid);
final boolean isValid = CUID.isValid("cl9gts1kw00393647w1z4v2tc");
System.out.println("Is 'cl9gts1kw00393647w1z4v2tc' a valid CUID ? " + isValid);
License
This project is released under terms of the MIT license.