What is UUID v5?
UUID version 5 is a namespace-based 128-bit identifier (36-char string) defined in RFC 4122. It combines:
- Namespace UUID: Pre-defined or custom UUID to scope the generation
- Name: User-defined string value within the namespace
- SHA-1 hash: Cryptographic algorithm used to generate the result
Format example: 2ed6657d-e927-5eb1-9a03-0242ac130003
How UUID v5 works
- Select a namespace UUID (pre-defined or custom)
- Concatenate the namespace UUID and the name string
- Compute SHA-1 hash of the concatenated value
- Set version bits (0101) and variant bits (10)
- Assemble as 32 hex digits with hyphens: 8-4-4-4-12 format
Advantages & Considerations
Advantages | Considerations |
---|---|
|
|
UUID v5 Structure
Bits | Content |
---|---|
0-47 | First 48 bits of SHA-1 hash |
48-51 | Version (0101 for v5) |
52-63 | Next 12 bits of SHA-1 hash |
64-65 | Variant (10 for RFC4122) |
66-127 | Remaining 62 bits of SHA-1 hash |
UUID v5 vs. other versions
Version | Based on | Use case | Privacy |
---|---|---|---|
UUID v1 | Time + MAC | Time-ordered IDs | ⚠️ Reveals MAC |
UUID v3 | Namespace + MD5 | Deterministic IDs | ✅ Private |
UUID v4 | Random | Secure random IDs | ✅ Private |
UUID v5 | Namespace + SHA-1 | Deterministic IDs | ✅ Private |
UUID v6 | Time (reordered) | Sortable IDs | ⚠️ Reveals MAC |
UUID v7 | Time + random | Sortable IDs | ✅ Private |
Predefined Namespaces
Namespace | UUID | Purpose |
---|---|---|
DNS | 6ba7b810-9dad-11d1-80b4-00c04fd430c8 | For domain names |
URL | 6ba7b811-9dad-11d1-80b4-00c04fd430c8 | For URLs |
OID | 6ba7b812-9dad-11d1-80b4-00c04fd430c8 | For ISO OIDs |
X.500 DN | 6ba7b814-9dad-11d1-80b4-00c04fd430c8 | For X.500 Distinguished Names |
Common Use Cases
- Content addressing: Consistent IDs for identical content
- Distributed systems: Named resources across systems
- URL mapping: Converting URLs to stable identifiers
- Configuration management: Tracking named configuration items
- Data deduplication: Identifying identical records
- Federation: Consistent cross-system identifiers
Frequently Asked Questions
Is UUID v5 better than UUID v3?
Yes, for most use cases. UUID v5 uses SHA-1 which is cryptographically stronger than the MD5 algorithm used in UUID v3. However, both provide deterministic generation.
Can UUID v5 values collide?
Collisions are theoretically possible but extremely unlikely in practice due to the properties of SHA-1. Using different namespaces or name strings virtually eliminates collision risk.
Is SHA-1 secure enough for UUID v5?
For UUID purposes, SHA-1 remains suitable despite its cryptographic weaknesses. UUID v5 is not intended for security purposes but for generating consistent identifiers.
Can I create my own namespace for UUID v5?
Yes. While RFC 4122 defines standard namespaces (DNS, URL, OID, X.500), you can create custom namespaces using any valid UUID, typically a v4 random UUID.
Will the same name always generate the same UUID v5?
Yes, but only within the same namespace. The same name in different namespaces will generate different UUIDs, which is a key feature for organizing identifiers.