Expand description
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§
- serde
- Hex encoding with
serde.
Enums§
- From
HexError - The error type for decoding a hex string into
Vec<u8>or[u8; N].
Traits§
Functions§
- decode
- Decodes a hex string into raw bytes.
- decode_
to_ slice - Decode a hex string into a mutable bytes slice.
- deserialize
- Deserializes a hex string into raw bytes.
- encode
- Encodes
dataas hex string using lowercase characters. - encode_
to_ slice - Encodes some bytes into a mutable slice of bytes.
- encode_
upper - Encodes
dataas hex string using uppercase characters. - serialize
- Serializes
dataas hex string using lowercase characters. - serialize_
upper - Serializes
dataas hex string using uppercase characters.