std.hex
Types
struct DecodeHexError
Functions
decode
pub fn decode(s: string): Bytes throws DecodeHexError
Decodes a hex string into raw bytes.
decode
pub fn decode(s: string): Bytes throws DecodeHexError
Decodes a hex string into raw bytes.
Decodes a hex string into raw bytes.
Example
nv
use std.hex;
use std.io.Bytes;
let bytes = try! hex.decode("deadbeef");
assert_eq bytes, Bytes.from_array([0xde, 0xad, 0xbe, 0xef]);
Encodes data
as hex string.
Encodes data
as hex string.
Encodes data
as hex string.
Arguments
uppercase
: Whether to use uppercase letters for encoding.
Example
nv
use std.hex;
use std.io.Bytes;
let h = hex.encode(Bytes.from_array([0xde, 0xad, 0xbe, 0xef]), uppercase: true);
assert_eq h, "DEADBEEF";
let h = hex.encode(Bytes.from_array([0xde, 0xad, 0xbe, 0xef]));
assert_eq h, "deadbeef";