wire / encoding / base32hex

base32hex (RFC 4648 §7, Extended Hex alphabet)

base32hex is the 'Extended Hex' Base32 variant from RFC 4648 §7: the same 5-bits-per-character block codec as standard Base32, but over the order-preserving alphabet '0123456789ABCDEFGHIJKLMNOPQRSTUV'. Because the alphabet is monotonic, the lexicographic order of encoded strings matches the byte order of the inputs, which is why DNSSEC NSEC3 (RFC 5155) uses it. Output is padded with '=' to a multiple of 8 characters.

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

aka: base32-hex · base32 extended hex · RFC 4648 base32hex

test vectors

RFC4648 · alphabet: 0123456789ABCDEFGHIJKLMNOPQRSTUV

inputoutputnote
utf8 ascii RFC 4648 §10 test vector: BASE32-HEX("") = "".
f utf8 CO====== ascii RFC 4648 §10 test vector: BASE32-HEX("f") = "CO======".
fo utf8 CPNG==== ascii RFC 4648 §10 test vector: BASE32-HEX("fo") = "CPNG====".
foo utf8 CPNMU=== ascii RFC 4648 §10 test vector: BASE32-HEX("foo") = "CPNMU===".
foob utf8 CPNMUOG= ascii RFC 4648 §10 test vector: BASE32-HEX("foob") = "CPNMUOG=".
fooba utf8 CPNMUOJ1 ascii RFC 4648 §10 test vector: BASE32-HEX("fooba") = "CPNMUOJ1" (5 bytes -> 8 chars, no padding).
foobar utf8 CPNMUOJ1E8====== ascii RFC 4648 §10 test vector: BASE32-HEX("foobar") = "CPNMUOJ1E8======".
CPNMUOJ1E8====== ascii foobar utf8 Round-trip: BASE32-HEX-decode("CPNMUOJ1E8======") = "foobar".

provenance

see also

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