decode_hex_20

Function decode_hex_20 

Source
pub fn decode_hex_20(hex: &[u8; 40]) -> Option<[u8; 20]>
Expand description

Decode a 40-hex-character string into a 20-byte array.

The input must be exactly 40 hexadecimal ASCII bytes. Returns None if any character is not a valid hex digit.

Example:

let hex = *b"00112233445566778899aabbccddeeff00112233";
let bytes = decode_hex_20(&hex).unwrap();
assert_eq!(bytes.len(), 20);