-
Notifications
You must be signed in to change notification settings - Fork 43
1.3. UUIDv3
Fabio Lima edited this page Sep 25, 2022
·
3 revisions
Creating a Name-based UUID:
String name = "https://github.com/";
UUID uuid = UuidCreator.getNameBasedMd5(UuidNamespace.NAMESPACE_URL, name);
List of predefined namespaces:
-
UuidNamespace.NAMESPACE_DNS
: Name string is a fully-qualified domain name; -
UuidNamespace.NAMESPACE_URL
: Name string is a URL; -
UuidNamespace.NAMESPACE_ISO_OID
: Name string is an ISO Object ID; -
UuidNamespace.NAMESPACE_X500_DN
: Name string is an X.500 Distinguished Name (in DER or a text output format).
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");