UUID v5 Generator
Press c to copy
Inputs
The same namespace and name always produce the same ID.
6ba7b810-9dad-11d1-80b4-00c04fd430c8
What is UUID v5?
A v5 UUID is derived, not generated. It is the SHA-1 hash of a name inside a namespace, with the version and variant bits overwritten. The same namespace and name always produce the same UUID, on any machine, forever.
That makes v5 useful for giving a stable ID to something that already has a natural key: a hostname, a URL, a file path. You never have to store the mapping, because you can recompute it.
v5 or v3?
They are the same construction with a different hash. v5 uses SHA-1 and v3 uses MD5, which makes v5 slower.
Neither hash is fit for security work any more, and neither UUID is reversible enough to matter either way, because only 122 bits of the digest survive. Pick whichever your other systems already use; if nothing constrains you, v5 is the more common choice.
The predefined namespaces
RFC 9562 defines four namespaces for common kinds of name. They are themselves UUIDs, and any UUID can serve as a namespace of your own.
- DNS — 6ba7b810-9dad-11d1-80b4-00c04fd430c8
- URL — 6ba7b811-9dad-11d1-80b4-00c04fd430c8
- OID — 6ba7b812-9dad-11d1-80b4-00c04fd430c8
- X.500 — 6ba7b814-9dad-11d1-80b4-00c04fd430c8
Generate one in code
TypeScript
import { v5 as uuidv5 } from "uuid";
uuidv5("example.com", uuidv5.DNS);Python
import uuid
uuid.uuid5(uuid.NAMESPACE_DNS, "example.com")Go
import "github.com/google/uuid"
id := uuid.NewSHA1(uuid.NameSpaceDNS, []byte("example.com"))Rust
// uuid = { version = "1", features = ["v5"] }
use uuid::Uuid;
Uuid::new_v5(&Uuid::NAMESPACE_DNS, b"example.com");What is a UUID?
A UUID is a Universally Unique IDentifier: a 128-bit number used to identify something without coordinating with anyone else. It is usually written as 32 hexadecimal characters in five hyphenated groups.
UUIDs come in several versions. v4 is random, v1 and v6 encode a timestamp and a MAC address, v3 and v5 hash a name inside a namespace, and v7 encodes a Unix millisecond timestamp followed by random bits.
Why use UUIDs?
UUIDs can be generated anywhere, by anyone, with no central authority, and still be safely assumed not to collide. That makes them useful for distributed systems, offline clients, and merging data from separate databases.
They are also instantly recognisable, which makes them easy to pick out of logs.
Some databases (for example Postgres) store a UUID as a 128-bit integer rather than a 36-character string, so using one as a primary key costs far less than it looks.
What are the downsides?
Uniqueness is probabilistic, not guaranteed. The odds of two v4 UUIDs colliding are negligible, but they are not zero.
Some versions leak information. A v1 or v6 UUID contains the MAC address of the machine that generated it and the moment it was generated, which is enough to correlate a device across systems. You can see exactly what a UUID gives away with the UUID decoder.
Time-ordered IDs are also partly guessable, so they are a poor choice for anything that doubles as a secret, such as a password reset token.