تولیدکننده UUID v3
تولید UUID v3 قطعی مبتنی بر نام با MD5
Namespace
6ba7b810-9dad-11d1-80b4-00c04fd430c8
نام
UUID v3 تولیدشده
What is UUID v3?
UUID v3 is a name-based UUID version defined in RFC 4122. Instead of random data or a timestamp, it derives the UUID deterministically from two inputs: a namespace UUID and a name string. The namespace + name pair is hashed using MD5, and the resulting hash is formatted as a UUID.
The key property of UUID v3 is determinism: the same namespace and name will always produce the identical UUID, on any machine, at any time. This makes it suitable for content-addressing — generating stable identifiers for resources that are identified by a meaningful name.
UUID v3 uses MD5 as its hash function. MD5 is considered cryptographically broken for security purposes, which is why UUID v5 (which uses SHA-1) is generally preferred for new development. Neither v3 nor v5 provides any randomness — they are purely deterministic.
Standard Namespaces
RFC 4122 defines four pre-assigned namespace UUIDs. Using a standard namespace ensures interoperability — two independent implementations will produce the same UUID v3 for the same name within the same namespace:
| Namespace | UUID | Use for |
|---|---|---|
| DNS | 6ba7b810-9dad-11d1-80b4-00c04fd430c8 | Fully qualified domain names (e.g. 'example.com') |
| URL | 6ba7b811-9dad-11d1-80b4-00c04fd430c8 | URLs and URIs (e.g. 'https://example.com/resource') |
| OID | 6ba7b812-9dad-11d1-80b4-00c04fd430c8 | ISO Object Identifiers (e.g. '1.2.840.113556') |
| X.500 | 6ba7b814-9dad-11d1-80b4-00c04fd430c8 | X.500 Distinguished Names (e.g. 'cn=John,dc=example,dc=com') |
You can also use any arbitrary UUID as a custom namespace — for example, a UUID v4 you generate once and embed in your application as a constant. This lets you create a private namespace for your own name-to-UUID mappings.
UUID v3 vs UUID v5
UUID v3 and UUID v5 are structurally identical — both are deterministic, name-based UUIDs. The only difference is the hash function:
- Uses MD5 hashing
- 128-bit output (UUID-sized)
- Defined in RFC 4122
- MD5 is cryptographically broken
- Supported by all UUID libraries
- Uses SHA-1 hashing
- 160-bit hash truncated to 128 bits
- Defined in RFC 4122
- SHA-1 is deprecated for security use but stronger than MD5
- Supported by all UUID libraries
Prefer UUID v5 over UUID v3 for all new development. The SHA-1 hash is stronger than MD5, and the performance difference is negligible. Use UUID v3 only when you need to reproduce UUIDs from a system that already uses it.
When to Use UUID v3
UUID v3 (and v5) are appropriate when you need a stable, reproducible identifier derived from a meaningful name — rather than a random ID that must be stored and looked up:
Understanding Determinism
The determinism of UUID v3 is both its greatest strength and its most important constraint. Given any namespace UUID and any name string, the output UUID is completely fixed — no randomness is involved. This means:
Always produces: 9073926b-929f-31c2-abc9-fad77ae3e8eb
If an attacker knows the namespace and can guess the name, they can compute the UUID in advance. UUID v3 values should never be used as unpredictable tokens, session IDs, or secrets. Use UUID v4 for any security-sensitive identifier.
Code Examples
UUID v3 requires a namespace UUID and a name string. Use the standard uuid package:
// Browser / Node.js — UUID v3 without dependencies
function uuidV3(namespace, name) {
// namespace must be a UUID string like '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
const nsBytes = namespace.replace(/-/g, '').match(/../g).map(h => parseInt(h, 16))
const nameBytes = [...new TextEncoder().encode(name)]
const combined = new Uint8Array([...nsBytes, ...nameBytes])
// md5(combined) — use your preferred MD5 library or the inline implementation
const hash = md5(combined) // returns Uint8Array(16)
hash[6] = (hash[6] & 0x0f) | 0x30 // version 3
hash[8] = (hash[8] & 0x3f) | 0x80 // variant
const h = [...hash].map(b => b.toString(16).padStart(2, '0')).join('')
return `${h.slice(0,8)}-${h.slice(8,12)}-${h.slice(12,16)}-${h.slice(16,20)}-${h.slice(20)}`
}
// Using the 'uuid' npm package
import { v3 as uuidv3 } from 'uuid'
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
console.log(uuidv3('example.com', uuidv3.DNS))
// → '9073926b-929f-31c2-abc9-fad77ae3e8eb' (always the same)import uuid
# Using the standard library
dns_uuid = uuid.uuid3(uuid.NAMESPACE_DNS, 'example.com')
print(dns_uuid)
# → 9073926b-929f-31c2-abc9-fad77ae3e8eb
url_uuid = uuid.uuid3(uuid.NAMESPACE_URL, 'https://example.com/page')
print(url_uuid)
# Custom namespace
MY_NS = uuid.UUID('a1b2c3d4-e5f6-7890-abcd-ef1234567890')
custom = uuid.uuid3(MY_NS, 'my-entity-name')
print(custom)package main
import (
"fmt"
"github.com/google/uuid"
)
func main() {
// Standard DNS namespace
ns := uuid.MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
id := uuid.NewMD5(ns, []byte("example.com"))
fmt.Println(id)
// → 9073926b-929f-31c2-abc9-fad77ae3e8eb
// URL namespace
urlNS := uuid.MustParse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
idURL := uuid.NewMD5(urlNS, []byte("https://example.com/page"))
fmt.Println(idURL)
}