Function zeros::hex_to_bytes

source ·
pub fn hex_to_bytes<H>(hex: H) -> Result<Vec<u8>>
where H: AsRef<[u8]>,
Expand description

§Converts a hexadecimal string into a vector of bytes

It requires 2 hexadecimal characters per byte.

§Examples

assert_eq!(zeros::hex_to_bytes("aaff00")?, [0xaa, 0xff, 0x00]);
assert_eq!(zeros::hex_to_bytes("C0FFEE")?, [0xc0, 0xff, 0xee]);