Skip to main content

encode_into_constant_time

Function encode_into_constant_time 

Source
pub const fn encode_into_constant_time(
    output: &mut [u8],
    data: &[u8],
    alphabet: Alphabet,
) -> Result<(), EncodeError>
Expand description

Constant-time hex encoding. Processes all input data without secret-dependent branches or memory accesses, making it suitable for cryptographic applications.

Consumers may prefer the faster encode_into which dispatches to a SIMD-accelerated path when available (non constant-time).

ยงExample

let mut buf = [0u8; 10];
hex::encode_into_constant_time(&mut buf, b"hello", hex::Alphabet::Lower).unwrap();
assert_eq!(&buf, b"68656c6c6f");