code wiki / (root) / nx_hex_codec.nx

nx_hex_codec.nx

buildroot/runtime/nx_hex_codec.nx

3488 B103 linesdepth 2pulls 2 transitivereach 7 importersview sourcekind tooltopic hex
docsdependenciesstructsconstsfunctions

about

hex.nx -- lowercase hex encoder + decoder. Complement to base64.nx for the common "print bytes as text" use cases where readability matters more than density: - SHA-256 / SHA-3 digest display - Git-style object IDs - TLS handshake transcripts for debugging - URL query parameters carrying short binary values Deterministic output (lowercase always). Decoder tolerates both upper and lower case. No "0x" prefix, no whitespace. Invariants: H1 Encoder output is exactly 2*n chars for n input bytes. H2 Decoder requires even-length input; rejects odd-length with a negative return. H3 Decoder rejects any non-hex char (not [0-9A-Fa-f]) with a negative return -- no silent skip. H4 Round-trip is exact: decode(encode(x)) == x for any byte sequence.

dependencies 1 imports · 5 importers

nx_syscalls.nx nx_hex_codec.nx nx_digest_auth.nx nx_etag.nx nx_f6_gate.nx nx_md5_kat.nx nx_uuid_v1.nx

imports: nx_syscalls.nx

imported by: nx_digest_auth.nxnx_etag.nxnx_f6_gate.nxnx_md5_kat.nxnx_uuid_v1.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap hex_encode hex_decode hex_nibble

structs

none

consts

30const HEX_ERR_ODD_LENGTH: i64 = -1
31const HEX_ERR_INVALID_CHAR: i64 = -2

functions

35func hex_encode(in_bytes: *u8, n: i64, out: *u8) -> i64
53func hex_nibble(c: i64) -> i64
called by 1: hex_decode
62func hex_decode(in_chars: *u8, n: i64, out: *u8) -> i64
called by 1: main calls 1: hex_nibble
80func main() -> i64