hex.nx
buildroot/runtime/hex.nx
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 · 4 importers
imports: syscalls.nx
imported by: digest_auth.nxetag.nxf6_gate.nxuuid.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 24 | const HEX_ERR_ODD_LENGTH: i64 = -1 |
| 25 | const HEX_ERR_INVALID_CHAR: i64 = -2 |
functions
| 29 | func hex_encode(in_bytes: *u8, n: i64, out: *u8) -> i64 { |
| 47 | func hex_nibble(c: i64) -> i64 {
called by 1: hex_decode |
| 56 | func hex_decode(in_chars: *u8, n: i64, out: *u8) -> i64 { |
| 74 | func main() -> i64 { |