const StdAlphabet, CrockfordAlphabet
Alphabets.
Package base32 implements RFC 4648 base32 and Crockford base32 as a pure, reusable package.
gno.land/p/moul/x/daily/base32/v0RFC 4648 and Crockford base32 — Encode, EncodeUnpadded,
EncodeCrockford, Decode, DecodeCrockford.
1import "gno.land/p/moul/x/daily/base32/v0"
2
3base32.Encode("foobar") // "MZXW6YTBOI======"
4base32.EncodeCrockford("hello") // "D1JPRV3F"
5base32.DecodeCrockford("d1-jprv3f") // "hello" — case folded, hyphen ignored
Two alphabets, for two different jobs. RFC 4648 (A–Z, 2–7, = padding)
is the interoperable one — use it when something else has to decode the result.
Crockford (0–9, A–Z minus I, L, O, U) is designed to be read aloud
and typed back: decoding folds case, reads I/L as 1 and O as 0, and
ignores hyphens, so a mis-heard identifier still decodes. U is excluded to
avoid accidental obscenities.
Verified against the RFC 4648 §10 vectors at every partial-group length, and the demo's pinned output is that vector set — so the example doubles as a conformance test.
Decoding is strict where it matters: leftover bits after the final byte must be
zero padding, never data, so "MB" is rejected rather than silently
truncated. It is lenient where it is safe: lowercase and missing padding are
accepted.
Base32 costs 60% expansion (8 characters per 5 bytes) against base64's 33%. You pay that to get an alphabet that survives case-insensitive systems and the telephone.
Live demo: r/moul/x/daily/base32demo
· render it at /r/moul/x/daily/base32demo/v0.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.
Package base32 implements RFC 4648 base32 and Crockford base32 as a pure, reusable package.
Two alphabets, for two different jobs:
Base32 costs 60% expansion (8 characters per 5 bytes) versus base64's 33%. You take that hit to get an alphabet that survives case-insensitive systems and being read over the phone.
A live demo of this package is at r/moul/x/daily/base32demo(/r/moul/x/daily/base32demo/v0).
Decode parses RFC 4648 base32, tolerating lowercase and missing padding.
DecodeCrockford parses Crockford base32, folding case, reading I/L as 1 and O as 0, and ignoring hyphens.
Encode returns the RFC 4648 base32 of src, with '=' padding.
EncodeCrockford returns Crockford base32, which is never padded.
EncodeUnpadded returns RFC 4648 base32 without padding.