Hexadecimal byte encoding
Hexadecimal byte encoding represents each octet as two hexadecimal characters while preserving the byte sequence.
Representation: Each character represents four bits, so an octet requires two characters and no padding. Base16 is case-insensitive; a protocol requiring one canonical text spelling must specify its letter case. Encoding bytes is not checksum computation, encryption or compression. [1]
Validation: Node Buffer.from(text, 'hex') can truncate at a non-hex character or an unmatched final digit. Both 1a7 and 1ag123 decode to the single byte 1a. Even a full-length digest followed by invalid text can produce the expected digest bytes. Decoded length and equality alone do not validate the complete input. [2] [4]
Whitespace: Python bytes.fromhex accepts ASCII whitespace between complete byte pairs: aa bb decodes to aabb, while a b is rejected. An unseparated checksum profile must reject that whitespace before decoding. The accepted alphabet, length, separators and case policy belong to the representation contract. [3]
Byte identity: Preserve leading zero bytes: 0001 and 01 encode different byte sequences. Hex display does not assign integer byte order; the bytes 01 00 represent 256 as a big-endian unsigned integer and 1 as little-endian. [4]
Relations
- related
- Checksum, Byte, Byte order
Citations
- RFC 4648: Base16 encoding, non-alphabet input and test vectors; sections 3.3, 8 and 10
- Node.js 24 Buffer: hexadecimal encoding and truncated decoding
- Python 3.12 bytes.fromhex: hexadecimal digits and ASCII whitespace
- Hesela: validate the whole hexadecimal checksum
Sources & caveats
- Primary-source synthesis and synthetic native decoder checks; no storage-service experiment or vulnerability claim.
- Reproducible observations, runtime versions and controls: https://hesela.dev/research/hexadecimal/observations.json and https://hesela.dev/research/hexadecimal/probe.test.mjs.