By the Withuse team · Updated
What is UUID v5?
UUID v5 hashes a namespace UUID and a name with SHA-1 and formats 128 bits of the digest as a UUID. It is the recommended name-based version: deterministic, collision-resistant for identifier purposes, and reproducible across systems.
When is a deterministic UUID useful?
Whenever the same logical entity must map to the same ID everywhere: deriving stable IDs from URLs or file paths, idempotency keys, merging datasets from independent sources, or content-addressable references — all without a shared database.
Example
Using the DNS namespace with the name example.com always produces cfbff0d1-9375-5685-968c-48ce8b15ae17 — on any machine, in any language, forever.
Frequently asked questions
Can I recover the original name from a UUID v5?
No. v5 applies SHA-1 to the namespace and name, keeps 128 bits of the digest, and overwrites 6 of them with the version and variant markers — so the result is a one-way, lossy derivation. What you can do is verify: if you already suspect a particular namespace and name, hash them again and compare. That makes v5 useful for idempotency checks and deduplication, but useless as a way to store data you need to read back. It also means a v5 UUID is not a secret. If the underlying name is guessable (an email address, a sequential internal ID), anyone can reproduce the UUID, so never use one as an access token.
Should I use v5 or v4 for my primary keys?
Use v5 only when the identity of a row is genuinely determined by its content, and v4 or v7 otherwise. The advantage of v5 is that two services can independently derive the same key for the same entity with no shared database and no coordination — ideal for merging feeds, importing external records, or making imports idempotent. The trap is that the derivation becomes part of your schema: if you ever change the name format, every derived key changes with it, and rows silently duplicate. Most tables do not need that guarantee, and for them a time-ordered v7 key gives better index behaviour with no coupling between an identifier and the data it points at.
Need a different version? Try the full UUID generator supporting v1, v3, v4, v5 and v7. All versions follow RFC 9562.