UUID v4 generation, parsing, and validation.
Implements RFC 4122 UUID v4 (random):
UUID v4 generation, parsing, and validation. Implements RFC 4122 UUID v4 (random): - 36-char hex-hyphenated string (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) - 122 bits of randomness, version 4 (0100), variant 1 (10xx) - Pure Clojure, zero dependencies beyond java.security.SecureRandom
(decode s)Decode a UUID v4 string into a 16-byte byte array. Returns nil if s is not a valid UUID.
(decode "550e8400-e29b-41d4-a716-446655440000") ;; => #object["[B" 0x...]
Decode a UUID v4 string into a 16-byte byte array. Returns nil if s is not a valid UUID. (decode "550e8400-e29b-41d4-a716-446655440000") ;; => #object["[B" 0x...]
(encode byte-arr)Encode a 16-byte byte array into a UUID v4 string.
(encode (byte-array 16 (range 16))) ;; => "00010203-0405-0607-0809-0a0b0c0d0e0f"
Encode a 16-byte byte array into a UUID v4 string. (encode (byte-array 16 (range 16))) ;; => "00010203-0405-0607-0809-0a0b0c0d0e0f"
(gen)Generate a new UUID v4 string. Returns a 36-character RFC 4122 UUID string.
(gen) ;; => "550e8400-e29b-41d4-a716-446655440000"
Generate a new UUID v4 string. Returns a 36-character RFC 4122 UUID string. (gen) ;; => "550e8400-e29b-41d4-a716-446655440000"
(valid? s)Return true if s is a valid UUID v4 string (36-char hex-hyphenated, version 4).
(valid? "550e8400-e29b-41d4-a716-446655440000") ;; => true
(valid? "not-a-uuid") ;; => false
Return true if s is a valid UUID v4 string (36-char hex-hyphenated, version 4). (valid? "550e8400-e29b-41d4-a716-446655440000") ;; => true (valid? "not-a-uuid") ;; => false
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |