Skip to main content

Crate rune_hex

Crate rune_hex 

Source
Expand description

Hex encoding and decoding for byte slices and files.

Converts between raw bytes and their hexadecimal string representation. Decoding accepts mixed-case input and optional 0x prefix. The library has zero dependencies.

§Features

  • encode — encode bytes to a lowercase hex string.
  • encode_upper — encode bytes to an uppercase hex string.
  • decode — decode a hex string to bytes; accepts mixed case and 0x prefix.
  • HexError — error type for malformed input.

§Quick Start

use rune_hex::{encode, decode};

let hex = encode(b"hello");
assert_eq!(hex, "68656c6c6f");

let bytes = decode(&hex).unwrap();
assert_eq!(bytes, b"hello");

Enums§

HexError
Error returned when decode encounters invalid hex input.

Functions§

decode
Decodes a hex string to bytes.
encode
Encodes bytes as a lowercase hex string.
encode_upper
Encodes bytes as an uppercase hex string.