const_hex

Function encode

source
pub fn encode<T: AsRef<[u8]>>(data: T) -> String
Available on crate feature alloc only.
Expand description

Encodes data as a hex string using lowercase characters.

Lowercase characters are used (e.g. f9b4ca). The resulting string’s length is always even, each byte in data is always encoded using two hex digits. Thus, the resulting string contains exactly twice as many bytes as the input data.

§Examples

assert_eq!(const_hex::encode("Hello world!"), "48656c6c6f20776f726c6421");
assert_eq!(const_hex::encode([1, 2, 3, 15, 16]), "0102030f10");