std/text/uuid
std/uuid — RFC 4122 UUID v4 (random) generation and parsing.
Generation is backed by std/random's xoshiro256 stream — fast,
but NOT suitable for security tokens (the seed is wall-clock-based
and observable). Use a real CSPRNG for crypto-grade IDs; this module
is for "a unique-enough string for a log line / cache key".
Generation stays native (shared global RNG state). Validation and
normalisation are pure Axle: both accept either the canonical
36-character dashed form or any dash placement, requiring exactly 32
hex digits once dashes are removed.
Free functions
| Type | Method and description |
|---|---|
| uuidV4() : string A fresh random (RFC 4122 v4) UUID in canonical 36-character dashed form, e.g. "f81d4fae-7dec-41d0-a765-00a0c91e6bf6". Not for securitytokens — see the module header. |
| uuidV4Hex() : string A fresh random v4 UUID as 32 hex digits with no dashes. |
| uuidIsValid(s : string) : bool true when s is a valid UUID: removing every '-' must leaveexactly 32 hex digits. |
| uuidNormalize(s : string) : string Validate s, then return its 32 hex digits with dashes removed andany uppercase digits lowered. Raises ParseException when s is nota valid UUID. |
Method detail
#uuidV4
A fresh random (RFC 4122 v4) UUID in canonical 36-character dashed
form, e.g. "f81d4fae-7dec-41d0-a765-00a0c91e6bf6". Not for security
tokens — see the module header.
#uuidV4Hex
A fresh random v4 UUID as 32 hex digits with no dashes.
#uuidIsValid
true when s is a valid UUID: removing every '-' must leave
exactly 32 hex digits.
s candidate UUID string to validate#uuidNormalize
Validate s, then return its 32 hex digits with dashes removed and
any uppercase digits lowered. Raises ParseException when s is not
a valid UUID.
s UUID string to validate and canonicalise