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
u32digest words as lowercase hex. - u64_
to_ hex - Format a single
u64as 16 lowercase hex nibbles (big-endian word order). - u64_
words_ to_ hex - Format big-endian
u64digest words as lowercase hex.