uuid5.nx
buildroot/runtime/uuid5.nx
about
uuid5.nx -- UUIDv5 (SHA-1 namespace + name -> UUID).
RFC 4122 ยง4.3. Produces a DETERMINISTIC 128-bit UUID from a
namespace UUID + an arbitrary name. Same (ns, name) always
yields the same UUID. Used for:
- stable IDs derived from URLs (content hashing)
- deterministic object IDs in distributed systems
- test fixture IDs that don't drift between runs
- git-style content addressing without exposing the hash
Algorithm:
hash = SHA-1(namespace_uuid_bytes || name_bytes)
uuid[0..16] = hash[0..16] (take first 16 bytes)
uuid[6] = (uuid[6] & 0x0F) | 0x50 (version = 5)
uuid[8] = (uuid[8] & 0x3F) | 0x80 (variant = RFC 4122)
The RFC defines four standard namespace UUIDs for DNS, URL,
OID, and X.500 -- we expose them as byte constants. Callers
needing their own namespace mint a v4 UUID (uuid_v4_bytes)
once and reuse it forever.
Invariants:
U5 1 Output is 16 bytes (not the hyphenated string; use
uuid_format from uuid.nx to get the string form).
U5 2 Deterministic: pure function of (ns, name).
U5 3 Byte-for-byte compatible with Python's uuid.uuid5,
Node's uuid library, java.util.UUID.nameUUIDFromBytes.
dependencies 2 imports · 0 importers
imports: syscalls.nxnx_sha1.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 35 | func uuid_ns_dns() -> *u8 {
called by 1: main |
| 39 | func uuid_ns_url() -> *u8 { |
| 43 | func uuid_ns_oid() -> *u8 { |
| 47 | func uuid_ns_x500() -> *u8 { |
| 54 | func uuid_v5_bytes(namespace: *u8, name: *u8, name_len: i64, |
| 88 | func main() -> i64 { |