Why does Base64 map 3 octets to 4 characters? What's the math here?
While looking at the https://gitlab.com/jas/ietf-base-encoding/ work (revision of RFC 4648 - Base64 and friends), I asked myself: where do the octet-to-character ratios for Base 32/64 come from? Here's the answer: Name Base (size of alphabeth) Bits per character (log2(Base)) LCM (with 8 bits per octet) Byte aligned mapping (octets to characters) Ratio (ca) Binary (Base2) 2 1 8 1 -> 8 8.00 Quaternary (Base4) 4 2 8 1 -> 4 4.00 Octal (Base8) 8 3 24 3 -> 8 2.67 Hex (Base16) 16 4 (2 * 2) 8 1 -> 2 2.00 Base32 32 5 40 5 -> 8 1.60 Base64 64 6 (2 * 3) 24 3 -> 4 1.33 Base128 128 7 56 7 -> 8 1.14 Base256 256 8 (2 * 2 * 2) 8 1 -> 1 1.00



