wire / encoding / base45

Base45 (RFC 9285)

Base45 (RFC 9285) encodes binary data for use in QR codes: it takes input two bytes at a time, treats each pair as a big-endian 16-bit number, and writes it as three base-45 digits (least-significant first) over a 45-character alphabet that is exactly the QR-code 'alphanumeric mode' character set. A trailing single byte becomes two digits. It is denser in a QR code than Base64 and is the carrier for EU Digital COVID Certificates.

encoding kind encoding status standard verification verified tier A encoding@1

aka: base-45 · RFC 9285 base45 · QR alphanumeric base45

test vectors

RFC9285 · alphabet: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:

inputoutputnote
AB ascii BB8 ascii RFC 9285 §4.3 example 1: "AB" (0x4142, n=16706) -> "BB8".
Hello!! ascii %69 VD92EX0 ascii RFC 9285 §4.3 example 2: "Hello!!" -> "%69 VD92EX0" (note the literal space).
base-45 ascii UJCLQE7W581 ascii RFC 9285 §4.3 example 3: "base-45" -> "UJCLQE7W581".
ietf! ascii QED8WEX0 ascii RFC 9285 §A example: "ietf!" -> "QED8WEX0".
BB8 ascii AB ascii Round-trip: base45-decode("BB8") = "AB".

provenance

see also

agent: curl -H 'accept: application/json' wire.phall.io/encoding/base45 or /encoding/base45.json