Deterministic SHA-1 Namespace Hashing Architecture
Standard Reference: IETF RFC 4122 ยง4.3 / RFC 9562 ยง5.5 (Name-Based UUIDs using SHA-1)
160-Bit SHA-1 Digest Truncation & Bit Masking
A standard cryptographic SHA-1 algorithm outputs 160 bits (20 bytes) of hashed data, whereas standard UUID architecture requires precisely 128 bits (16 bytes).
Per RFC 4122/9562 specifications, Version 5 algorithms strictly utilize octets 0 through 15 (the first 16 bytes) of the SHA-1 digest, discarding the trailing 4 bytes (octets 16โ19). The algorithm then enforces the Version 5 and Variant 1 bitmasks:
time_hi_and_version[0] = (digest[6] & 0x0f) | 0x50
Forces the 13th hexadecimal character to always be 5.
clock_seq_hi_and_reserved = (digest[8] & 0x3f) | 0x80
Forces the 17th hexadecimal character to always be 8, 9, a, or b.
Distributed Systems Use Cases: Idempotency & Deduplication
๐ API Idempotency Keys
Construct deterministic transaction IDs from customer ID + order sequence without risking duplicate database billing.
๐๏ธ Cross-Database Sync
Assign identical universal primary keys to records synchronized across isolated CRM, analytics, and operational databases.
๐ URL & Asset Indexing
Convert arbitrary media URLs and file paths into uniform 16-byte database primary keys without collisions.
Multi-Language Code Implementation
import { v5 as uuidv5 } from 'uuid';
// Predefined DNS Namespace
const MY_DNS_NAMESPACE = uuidv5.DNS;
// Generate deterministic UUID v5 from domain:
const siteId = uuidv5('modernuuid.com', MY_DNS_NAMESPACE);
console.log(siteId);
// Always outputs identical UUID across all systems!
import uuid
# Predefined DNS Namespace
dns_ns = uuid.NAMESPACE_DNS
# Generate reproducible UUID v5:
v5_id = uuid.uuid5(dns_ns, 'modernuuid.com')
print(f"UUID v5: {v5_id}")