Crockford Base32 Encoder / Decoder
Crockford's human-friendly Base32 encoding (no I/L/O ambiguity).
Overview
Douglas Crockford's Base32 is a 32-character encoding designed to be easy for humans to read, type, and dictate over the phone. It drops the visually-similar characters I, L, O, and U from the alphabet, and decoding accepts mixed case plus a few obvious substitutions ("0" for O, "1" for I or L). The result is a compact, error-tolerant alternative to plain hex or standard Base32.
Engineers building short user-facing IDs, license keys, and order numbers reach for Crockford Base32 specifically because it survives being read out loud and rewritten by hand. This encoder/decoder converts arbitrary bytes to and from the format.
How it works
The alphabet is 0123456789ABCDEFGHJKMNPQRSTVWXYZ — digits 0–9 plus the 22 ASCII letters left after removing I, L, O, and U. Encoding takes binary input five bits at a time and outputs one character per group. An optional check character (one of 32 plus the symbols *~$=U) can be appended for error detection.
Worked example: the byte 0xFF (binary 11111111) splits into the 5-bit groups 11111 and 111 (padded). 11111 is index 31, which encodes to Z. The trailing partial group encodes to Y. So 0xFF becomes ZY (with implicit padding).
Examples
Input (bytes): Hello
Output: 91JPRV3F
Input (bytes): 0xCAFEBABE
Output: SBZ7NBY (approximate)
Decode input: 91jprv3f
Output: Hello
FAQ
How is this different from standard Base32 (RFC 4648)?
Standard Base32 uses A–Z plus 2–7 and is case-sensitive. Crockford uses a different alphabet, accepts case-insensitive input, and substitutes look-alikes during decoding — all aimed at human readability.
Why no I, L, O, or U?
I, L, and 1 look alike; O and 0 look alike; U is excluded so the encoding can't accidentally form profanity. Dropping them costs nothing because 32 distinct characters still fit easily.
Does it have padding?
No mandatory padding like standard Base32's = characters. Crockford specifies that bit groups are padded to a full character with zeros if necessary.