wire / encoding / base16

Base16 — hexadecimal (RFC 4648 §8)

Base16 is plain hexadecimal: each input byte becomes exactly two characters from the alphabet 0–9 A–F. There is no padding (every byte is a whole number of characters) and the canonical RFC 4648 form is uppercase, though virtually all tooling decodes either case. It is the most transcribable but least dense of the RFC 4648 family.

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

aka: base-16 · hex · hexadecimal · RFC 4648 base16

test vectors

RFC4648 · alphabet: 0123456789ABCDEF

inputoutputnote
666F6F626172 ascii foobar utf8 RFC 4648 §10 test vector, canonical UPPERCASE: BASE16("foobar") = "666F6F626172"; asserted here by decoding the uppercase string back to "foobar" (hex decode is case-insensitive).
foobar utf8 666f6f626172 ascii Encode of "foobar": the executor (Buffer.toString('hex')) emits lowercase '666f6f626172'; uppercase '666F6F626172' is the RFC-canonical equivalent.
f utf8 66 ascii BASE16("f") = "66" — single byte 0x66, two hex chars, no padding.
fo utf8 666f ascii BASE16("fo") = "666F" (RFC uppercase) / '666f' (executor lowercase).

provenance

see also

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