GUID / UUID V4 - Random-Based Identifier (Recommended)
GUID / UUID v4 is the most widely used random-based identifier. Learn about its structure, collision probability, advantages and why it is recommended for general-purpose applications.
GUID / UUID v5 is a name-based identifier that generates deterministic GUIDs / UUIDs by hashing a namespace UUID and a name using the SHA-1 algorithm. The same namespace and name combination always produces the same GUID / UUID, making it useful for stable, repeatable identifiers derived from existing data. V5 is the modern, preferred alternative to v3, which uses the weaker MD5 algorithm.
GUID / UUID v5 was defined in the original GUID / UUID specifications around 1997 and standardized in RFC 4122 in July 2005.
V5 is fully supported and has no deprecation concerns in both RFC 4122 and RFC 9562. It remains the recommended option for name-based, deterministic GUID / UUID generation, particularly when upgrading from v3.
For non-deterministic identifiers, consider v4 (random) or v7 (time-ordered).
Generation algorithm: GUID / UUID v5 is computed by concatenating the binary representation of the namespace UUID (16 bytes) and the name (as UTF-8 bytes), then hashing the result using SHA-1. The first 128 bits of the SHA-1 output (which produces 160 bits) are used as the base GUID / UUID, with version and variant bits overwritten.
Bit layout: GUID / UUID v5 follows the standard 128-bit layout with canonical string format (8-4-4-4-12). The value is derived from SHA-1 hash output, with reserved bits to indicate the version (5) and variant.
Deterministic generation: GUID / UUID v5 is fully deterministic. Given the same namespace and name, the same GUID / UUID will always be generated, regardless of when or where it is created.
Field Bits Hex Digits Description
─────────────────────────────────────────────────────────────────────────
hash_low 32 8 Low 32 bits of SHA-1 hash
hash_mid 16 4 Middle 16 bits of SHA-1 hash
hash_hi_and_version 16 4 High 12 bits of SHA-1 hash + 4-bit version (0101)
hash_seq_hi_and_reserved 8 2 2-bit variant (10) + 6 bits from SHA-1 hash
hash_seq_low 8 2 8 bits from SHA-1 hash
hash_node 48 12 48 bits from SHA-1 hash
Hash algorithm: SHA-1 produces a 160-bit (20-byte) output, but only the first 128 bits are used. The version bits (bits 12-15 of hash_hi_and_version) are set to 0101 (5 in hex). The variant bits (bits 6-7 of hash_seq_hi_and_reserved) are set to 10 for RFC 4122 compliance. All other bits come directly from the SHA-1 hash output.
Namespaces: RFC 4122 defines well-known namespace GUIDs / UUIDs:
• 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
Custom namespaces can also be used for application-specific requirements.
Try our GUID / UUID Inspector to see the hash-derived structure of v5 GUIDs / UUIDs.
GUID / UUID v5 uses the standard 8-4-4-4-12 canonical format with 32 hexadecimal digits separated by hyphens (36 characters total).
Canonical format: 8-4-4-4-12
Example (v5): 987fbc97-4bed-5078-8f07-9141ba07c9f3
Layout: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
^ ^
| └─ N = Variant: is typically 8, 9, a or b (RFC variant)
└────── M = Version: first hex digit of the 3rd group is "5" for v5
Practical rule: in the canonical string, the version is encoded as the first hex digit of the third group. For v5 it is 5. The variant is indicated by the high bits of the fourth group (often rendered as 8-b in hex for the common standard variant). The remaining bits are derived from the SHA-1 hash.
6ba7b810-9dad-11d1-80b4-00c04fd430c8 (for domain names)6ba7b811-9dad-11d1-80b4-00c04fd430c8 (for URLs)6ba7b812-9dad-11d1-80b4-00c04fd430c8 (for ISO OID)6ba7b814-9dad-11d1-80b4-00c04fd430c8 (for X.500 DNs)uuid npm package: uuid.v5(name, namespace)import uuid; uuid.uuid5(uuid.NAMESPACE_DNS, 'example.com')java.util.UUID.nameUUIDFromBytes() with SHA-1 (requires manual implementation)Faithlife.Utility or implement SHA-1 hashinguuid.NewV5(namespace, name) (with google/uuid package)Uuid::new_v5(namespace, name) (with uuid crate)GUID / UUID v5 is the preferred choice when you need deterministic, name-based identifiers without relying on randomness or coordination. It uses SHA-1 instead of MD5, making it more robust than v3 for most practical applications. While it should not be used for security-sensitive purposes, it is well-suited for stable mappings, idempotent operations, and derived identifiers in modern systems.
These articles expand on related concepts, formats and practical considerations.