uuid

Generate, parse, format, and validate Universally Unique Identifiers. Four variants are supported: v4 (fully random), v7 (timestamp-ordered with an intra-millisecond monotonic counter), and the name-based deterministic v5 (SHA-1) and v3 (MD5). Identifiers are 128-bit values carried as a canonical lowercase 8-4-4-4-12 string or as 16 raw bytes, with helpers for variant / version inspection, the nil UUID, and the four RFC 4122 namespace constants. parse is strict-canonical by default; pass a trailing true to also accept the lenient hyphen-less, urn:uuid:, and brace-wrapped forms.

uuid:v4

[$uuid:v4] -> string — Generate a random (RFC 4122 v4) UUID as a canonical string, using CSPRNG entropy.

            [?lib 'cx-stdlib/uuid']
[$uuid:validate [$uuid:v4]]
          
            cx-err:CXER0271
          

uuid:v7

[$uuid:v7] -> string — Generate a timestamp-ordered (RFC 9562 v7) UUID string, monotonic within a millisecond.

            [?lib 'cx-stdlib/uuid']
[$uuid:validate [$uuid:v7]]
          
            cx-err:CXER0271
          

uuid:v4-bytes

[$uuid:v4-bytes] -> bytes — Generate a random (v4) UUID as the raw 16-byte value.

            [?lib 'cx-stdlib/uuid']
[$uuid:version [$uuid:v4-bytes]]
          
            cx-err:CXER0271
          

uuid:v7-bytes

[$uuid:v7-bytes] -> bytes — Generate a timestamp-ordered (v7) UUID as the raw 16-byte value.

            [?lib 'cx-stdlib/uuid']
[$uuid:variant [$uuid:v7-bytes]]
          
            cx-err:CXER0271
          

uuid:v5

[$uuid:v5] -> string — Derive a deterministic name-based (SHA-1) UUID string from a namespace and name.

            [?lib 'cx-stdlib/uuid']
[$uuid:v5 [$uuid:ns-url] "https://example.com"]
          
            '4fd35a71-71ef-5a55-a9d9-aa75c889a6d0'
          

uuid:v3

[$uuid:v3] -> string — Derive a deterministic name-based (MD5) UUID string from a namespace and name.

            [?lib 'cx-stdlib/uuid']
[$uuid:v3 [$uuid:ns-dns] "www.example.com"]
          
            '5df41881-3aed-3515-88a7-2f4a814cf09e'
          

uuid:v5-bytes

[$uuid:v5-bytes] -> bytes — Derive a name-based (SHA-1) UUID as the raw 16-byte value.

            [?lib 'cx-stdlib/uuid']
[$uuid:format [$uuid:v5-bytes [$uuid:ns-dns] "www.example.com"]]
          
            '2ed6657d-e927-568b-95e1-2665a8aea6a2'
          

uuid:v3-bytes

[$uuid:v3-bytes] -> bytes — Derive a name-based (MD5) UUID as the raw 16-byte value.

            [?lib 'cx-stdlib/uuid']
[$uuid:version [$uuid:v3-bytes [$uuid:ns-dns] "x"]]
          
            3
          

uuid:parse

[$uuid:parse] -> bytes — Parse a UUID string into 16 bytes — strict-canonical by default, lenient on opt-in.

            [?lib 'cx-stdlib/uuid']
[$uuid:version [$uuid:parse [$uuid:v4]]]
          
            cx-err:CXER0271
          

uuid:format

[$uuid:format] -> string — Format 16 bytes as the canonical lowercase 8-4-4-4-12 hex string.

            [?lib 'cx-stdlib/uuid']
[$uuid:format [$uuid:parse "550e8400-e29b-41d4-a716-446655440000"]]
          
            '550e8400-e29b-41d4-a716-446655440000'
          

uuid:validate

[$uuid:validate] -> bool — Report whether a string is a well-formed canonical UUID.

            [?lib 'cx-stdlib/uuid']
[$uuid:validate [$uuid:v4]]
          
            cx-err:CXER0271
          

uuid:variant

[$uuid:variant] -> int — Report the RFC 4122 variant bits of a 16-byte UUID.

            [?lib 'cx-stdlib/uuid']
[$uuid:variant [$uuid:parse [$uuid:v4]]]
          
            cx-err:CXER0271
          

uuid:version

[$uuid:version] -> int — Report the version number (1-8) of a 16-byte UUID.

            [?lib 'cx-stdlib/uuid']
[$uuid:version [$uuid:parse [$uuid:v4]]]
          
            cx-err:CXER0271
          

uuid:nil-uuid

[$uuid:nil-uuid] -> string — Return the all-zero nil UUID string.

            [?lib 'cx-stdlib/uuid']
[$uuid:validate [$uuid:nil-uuid]]
          
            true
          

uuid:ns-dns

[$uuid:ns-dns] -> bytes — Return the RFC 4122 DNS namespace UUID as 16 bytes.

            [?lib 'cx-stdlib/uuid']
[$uuid:format [$uuid:ns-dns]]
          
            '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
          

uuid:ns-url

[$uuid:ns-url] -> bytes — Return the RFC 4122 URL namespace UUID as 16 bytes.

            [?lib 'cx-stdlib/uuid']
[$uuid:format [$uuid:ns-url]]
          
            '6ba7b811-9dad-11d1-80b4-00c04fd430c8'
          

uuid:ns-oid

[$uuid:ns-oid] -> bytes — Return the RFC 4122 ISO OID namespace UUID as 16 bytes.

            [?lib 'cx-stdlib/uuid']
[$uuid:format [$uuid:ns-oid]]
          
            '6ba7b812-9dad-11d1-80b4-00c04fd430c8'
          

uuid:ns-x500

[$uuid:ns-x500] -> bytes — Return the RFC 4122 X.500 DN namespace UUID as 16 bytes.

            [?lib 'cx-stdlib/uuid']
[$uuid:format [$uuid:ns-x500]]
          
            '6ba7b814-9dad-11d1-80b4-00c04fd430c8'