https://github.com/thibaultmeyer/cuid-java
Collision-resistant ids optimized for horizontal scaling and performance
https://github.com/thibaultmeyer/cuid-java
cuid cuid-generator cuid2 java
Last synced: 3 months ago
JSON representation
Collision-resistant ids optimized for horizontal scaling and performance
- Host: GitHub
- URL: https://github.com/thibaultmeyer/cuid-java
- Owner: thibaultmeyer
- License: mit
- Created: 2022-10-21T07:18:40.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-12-21T19:52:52.000Z (5 months ago)
- Last Synced: 2025-12-23T08:15:59.075Z (5 months ago)
- Topics: cuid, cuid-generator, cuid2, java
- Language: Java
- Homepage:
- Size: 52.7 KB
- Stars: 49
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# CUID for Java
[](https://raw.githubusercontent.com/thibaultmeyer/cuid-java/master/LICENSE)
[](https://github.com/thibaultmeyer/cuid-java/releases)
[](https://central.sonatype.com/artifact/io.github.thibaultmeyer/cuid)
[](https://github.com/thibaultmeyer/cuid-java)
[](https://javadoc.io/doc/io.github.thibaultmeyer/cuid)
Java implementation of CUID. Read more at CUID official website.
*****
## 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
```xml
io.github.thibaultmeyer
cuid
x.y.z
```
```java
final CUID cuid = CUID.randomCUID1();
System.out.println("CUID: " + cuid);
```
```java
final CUID cuid = CUID.randomCUID2();
System.out.println("CUID (Version 2): " + cuid);
```
```java
final int customLength = 8; // Length must be, at least, 1
final CUID cuid = CUID.randomCUID2(customLength);
System.out.println("CUID (Version 2): " + cuid);
```
```java
final CUID cuid = CUID.fromString("cl9gts1kw00393647w1z4v2tc");
System.out.println("CUID: " + cuid);
```
```java
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](https://raw.githubusercontent.com/thibaultmeyer/cuid-java/master/LICENSE).