szalansky / uuid-creator

A library for Universally Unique Identifiers (UUID).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UUID Creator

This is a Java library for generating Universally Unique Identifiers.

UUIDs:

  • UUID Version 1: the time-based version with gregorian epoch specified in RFC-4122;
  • UUID Version 2: the DCE Security version with embedded POSIX UIDs specified in DCE 1.1;
  • UUID Version 3: the name-based version that uses MD5 hashing specified in RFC-4122;
  • UUID Version 4: the randomly or pseudo-randomly generated version specified in RFC-4122;
  • UUID Version 5: the name-based version that uses SHA-1 hashing specified in RFC-4122;
  • UUID Version 6: the time-ordered version with gregorian epoch proposed as new UUID format;
  • UUID Version 7: the time-ordered version with Unix epoch proposed as new UUID format.

COMB GUIDs:

  • Prefix COMB GUID: a combination of random bytes with a prefix (millisecond);
  • Suffix COMB GUID: a combination of random bytes with a suffix (millisecond);
  • Short Prefix COMB GUID: a combination of random bytes with a small prefix (minute);
  • Short Suffix COMB GUID: a combination of random bytes with a small suffix (minute).

This project contains a micro benchmark and a good amount of unit tests.

The jar file can be downloaded directly from maven.org.

Read the Wiki pages and the Javadocs.

Maven dependency

Add these lines to your pom.xml:

<!-- https://search.maven.org/artifact/com.github.f4b6a3/uuid-creator -->
<dependency>
  <groupId>com.github.f4b6a3</groupId>
  <artifactId>uuid-creator</artifactId>
  <version>5.1.2</version>
</dependency>

See more options in maven.org.

Modularity

Module and bundle names are the same as the root package name.

  • JPMS module name: com.github.f4b6a3.uuid
  • OSGi symbolic name: com.github.f4b6a3.uuid

How to Use

All UUID types can be created from the facade UuidCreator.

Create a UUIDv1:

UUID uuid = UuidCreator.getTimeBased();

Create a UUIDv2:

UUID uuid = UuidCreator.getDceSecurity(UuidLocalDomain.LOCAL_DOMAIN_PERSON, 1234);

Create a UUIDv3:

UUID uuid = UuidCreator.getNameBasedMd5(UuidNamespace.NAMESPACE_URL, "https://github.com/");

Create a UUIDv4:

UUID uuid = UuidCreator.getRandomBased();

Create a UUIDv5:

UUID uuid = UuidCreator.getNameBasedSha1(UuidNamespace.NAMESPACE_URL, "https://github.com/");

Create a UUIDv6:

UUID uuid = UuidCreator.getTimeOrdered();

Create a UUIDv7:

UUID uuid = UuidCreator.getTimeOrderedEpoch();

Create a Prefix COMB:

UUID uuid = UuidCreator.getPrefixComb();

Create a Suffix COMB:

UUID uuid = UuidCreator.getSuffixComb();

Create a Short Prefix COMB:

UUID uuid = UuidCreator.getShortPrefixComb();

Create a Short Suffix COMB:

UUID uuid = UuidCreator.getShortSuffixComb();

Other identifier generators

Check out the other ID generators from the same family:

License

This library is Open Source software released under the MIT license.

About

A library for Universally Unique Identifiers (UUID).

License:MIT License


Languages

Language:Java 99.9%Language:Shell 0.0%Language:Batchfile 0.0%