base32h 0.2.0

Base32H for rust
Documentation
  • Coverage
  • 80%
    4 out of 5 items documented4 out of 4 items with examples
  • Size
  • Source code size: 35.52 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.35 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • jdon/Base32H
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jdon

Base32H

An implementation of base32. Built following the spec and test cases from https://base32h.github.io/

Installation

cargo add base32h

Usage

use base32h::{encode_binary_to_string, encode_to_string, decode_string_to_binary, decode_string};

assert_eq!(encode_to_string(1099511627775).unwrap(), "ZZZZZZZZ".to_owned());
assert_eq!(decode_string("ZZZZZZZZ"), Some(1099511627775));

assert_eq!(encode_binary_to_string(&[255, 255, 255, 255, 255, 255]), "0000007ZZZZZZZZZ".to_owned());
assert_eq!(decode_string_to_binary("zZzZzZzZ"), Vec::from([255, 255, 255, 255, 255]));

Test

Run: cargo test

Benchmarks

Run: cargo bench

Fuzzing

Install cargo fuzz:

cargo install cargo-fuzz

Run one of the fuzzing targets (Must be on nightly):

  • cargo fuzz run encode_binary_to_string -j 8 // 8 is the number of threads to use
  • cargo fuzz run decode_string_to_binary -j 8
  • cargo fuzz run encode_to_string -j 8
  • cargo fuzz run decode_string -j 8