code wiki / (root) / crockford32.nx

crockford32.nx

buildroot/runtime/crockford32.nx

6567 B197 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

crockford32.nx -- Crockford Base32 encoding. Douglas Crockford 2002: a base32 variant designed for human transcription. Removes I, L, O, U (visually similar to 1, 1, 0, V respectively) from the alphabet. Accepts mixed case + hyphens on decode (so \"4CQ-5M4D\" and \"4cq5m4d\" both decode to the same bytes). Alphabet: 0123456789ABCDEFGHJKMNPQRSTVWXYZ 0 1 0123456789012345678901234567890 1 Used by: - ULID (Universal Unique Lexicographically-sortable Identifier) -- 26-char ID, Crockford-32 over 128 bits - License keys, short-URL tokens, password reset tokens - Voicemail PINs, serial numbers for hardware Not RFC-standardised (RFC 4648 base32 is similar but uses a different alphabet and doesn't allow hyphens/mixed case). We ship both: base32.nx (RFC 4648) and this module (Crockford). Invariants: C1 Encoder output is upper-case only, no padding. C2 Decoder accepts mixed case + '-' between groups. C3 Round-trip exact: decode(encode(x)) == x.

dependencies 1 imports · 1 importers

syscalls.nx crockford32.nx ulid.nx

imports: syscalls.nx

imported by: ulid.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main c32_encode c32_enc_char c32_decode c32_dec_char

structs

none

consts

30const C32_ERR_SHORT: i64 = -1
31const C32_ERR_CHAR: i64 = -2

functions

34func c32_enc_char(n: i64) -> i64 {
63func c32_dec_char(c: i64) -> i64 {
called by 1: c32_decode
105func c32_encode(in_bytes: *u8, n: i64, out: *u8) -> i64 {
called by 1: main calls 1: c32_enc_char
131func c32_decode(chars: *u8, n: i64, out: *u8) -> i64 {
called by 1: main calls 1: c32_dec_char
161func main() -> i64 {