Module hex

Hexadecimal encoding and decoding.


hex provides encoding and decoding of binary data to and from hexadecimal strings.

Examples

Basic encoding and decoding:

use hex::{encode, decode};

let data = b"Hello, world!";
let hex_string = encode(data);
println!("Hex: {}", hex_string); // "48656c6c6f2c20776f726c6421"

let decoded = decode(&hex_string).unwrap();
assert_eq!(decoded, data);

Uppercase hex encoding:

use hex::encode_upper;

let data = b"ABC";
let hex_upper = encode_upper(data);
println!("Upper: {}", hex_upper); // "414243"

Modules

Traits

Functions