rune-hex 0.1.0

Hex encoding and decoding for byte slices and files — lowercase, uppercase, and streaming output
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented4 out of 5 items with examples
  • Size
  • Source code size: 16.12 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 334.17 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 31s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • alexile/runes
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alexile

rune-hex

Hex encoding and decoding for byte slices and files.

crates.io docs.rs license CI

Converts between raw bytes and hexadecimal strings. Decoding accepts lowercase, uppercase, mixed-case, and optional 0x prefix. The library has zero dependencies.

Installation

[dependencies]
rune-hex = "0.1"

CLI

cargo install rune-hex

Usage

Library

use rune_hex::{encode, encode_upper, decode};

assert_eq!(encode(b"\xde\xad\xbe\xef"),       "deadbeef");
assert_eq!(encode_upper(b"\xde\xad\xbe\xef"), "DEADBEEF");

assert_eq!(decode("deadbeef").unwrap(), b"\xde\xad\xbe\xef");
assert_eq!(decode("DEADBEEF").unwrap(), b"\xde\xad\xbe\xef");
assert_eq!(decode("0xDeAdBeEf").unwrap(), b"\xde\xad\xbe\xef");

CLI

# Encode a file
rune-hex encode firmware.bin

# Encode stdin
echo -n "hello" | rune-hex encode
# 68656c6c6f

# Uppercase output
echo -n "hello" | rune-hex encode --upper
# 68656C6C6F

# Decode hex to raw bytes
rune-hex decode deadbeef > out.bin

# Decode from stdin
echo "68656c6c6f" | rune-hex decode
# hello

# Decode with 0x prefix
rune-hex decode 0xdeadbeef > out.bin

License

MIT