Skip to main content

Module hex

Module hex 

Source
Expand description

Utilities for encoding, decoding, and displaying lowercase hex/base16 formatted data.

Encoding and decoding is also designed to be (likely) constant time (as much as we can without diving into manual assembly), which allows us to safely hex::encode and hex::decode secrets without potentially leaking bits via timing side channels.

Structs§

HexDisplay
Provides Debug and Display impls for a byte slice. Useful for displaying hex value without allocating via encode.

Enums§

DecodeError
Errors which can be produced while decoding a hex string.

Traits§

FromHex
A trait to deserialize something from a hex-encoded string slice.

Functions§

decode
Try to decode a hex string to owned bytes (Vec<u8>).
decode_const
A const fn to decode a hex string to a fixed-length array at compile time. Panics if the input was not a valid hex string.
decode_to_slice
Decodes a hex string into an output buffer. This is also designed to be (likely) constant time.
display
Get a HexDisplay which provides a Debug and Display impl for the given byte slice. Useful for displaying a hex value without allocating.
encode
Convert a byte slice to an owned hex string. If you simply need to display a byte slice as hex, use display instead, which avoids the allocation.