Skip to content

1.3. UUIDv3

Fabio Lima edited this page Sep 25, 2022 · 3 revisions

Name-based UUID with MD5 hashing

Creating a Name-based UUID:

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

List of predefined namespaces:

More examples

A name-based factory that uses a unique namespace defined for the application:

    // a random unique namespace for the application
    UUID namespace = UUID.fromString("b86919b5-d2b1-455e-8ef5-b752f3fa8416");

    // a name-based factory that uses the unique namespace
    NameBasedMd5Factory factory = new NameBasedMd5Factory(namespace);

    // use the factory as many times as needed
    UUID uuid = factory.create("This is a test string");
Clone this wiki locally