Skip to main content

Module hex

Module hex 

Source
Expand description

Hex encoding / decoding helpers used by test vectors. Hex formatting helpers for hash tests.

Per audit L.2.4 (perf): the prior implementations called format!("{byte:02x}") per byte / per word, which allocates a fresh String on every call. At internet-scale hashing (billions of digests) that’s a heap alloc per input byte. These helpers now use a 512-byte lookup table and push two characters per byte directly.

Functions§

bytes_to_hex
Format a byte slice as lowercase hex.
u32_words_to_hex
Format big-endian u32 digest words as lowercase hex.
u64_to_hex
Format a single u64 as 16 lowercase hex nibbles (big-endian word order).
u64_words_to_hex
Format big-endian u64 digest words as lowercase hex.