UUID Version 5 is another member of the UUID family designed for deterministic generation. Similar to UUID Version 3, it relies on hashing a namespace identifier and a name, but it utilizes the SHA-1 algorithm instead of MD5. This results in a 128-bit identifier that remains consistent for a given namespace and name combination.
The structure of UUID5 mirrors that of other UUID versions, featuring a 32-character hexadecimal representation. Key components include the UUID version (5), the namespace identifier, and the hashed value of the namespace identifier and name.
As specified in RFC 4122, here are the namespace identifiers for UUID Version 5:
DNS Namespace:
6ba7b810-9dad-11d1-80b4-00c04fd430c8
Fully Qualified Domain Names (FQDN) Namespace (UUID Version 5):
6ba7b812-9dad-11d1-80b4-00c04fd430c8
ISO Object Identifiers (OIDs) Namespace (UUID Version 5):
6ba7b814-9dad-11d1-80b4-00c04fd430c8
Using the URL namespace, below are the UUIDs for different URLs:
https://www.stackoverflow.com :
a700836c-978d-5f1e-acb8-39e8ce0d12eb
https://google.com :
9a4cda5b-12b5-5e03-822a-7d33af73bcf0
In this example, the namespace identifier and name were used to generate a deterministic UUID5.
UUID Version 5, much like UUID3, relies on deterministic hashing. However, it uses the more secure SHA-1 algorithm. For a given namespace identifier and name combination, the resulting UUID5 will always be the same. Deterministic hashing ensures reproducibility and consistency, making it valuable in scenarios where these qualities are paramount.
UUID5 finds applications in contexts where deterministically generated, reproducible identifiers are crucial. Examples include scenarios requiring unique identifiers for specific names within a defined namespace, such as generating consistent identifiers for objects or resources based on their names.
To implement UUID5, developers can use programming languages and libraries supporting UUID generation. The process involves specifying the namespace identifier and name and using the SHA-1 hashing algorithm to create the UUID5. While UUID5 may not be as widely used as some other versions, it excels in scenarios demanding deterministic uniqueness and enhanced security through the SHA-1 algorithm.