base32h

Crates.iobase32h
lib.rsbase32h
version0.2.0
sourcesrc
created_at2020-09-21 02:05:01.270061
updated_at2020-09-23 00:27:52.054229
descriptionBase32H for rust
homepage
repositoryhttps://github.com/jdon/Base32H/
max_upload_size
id290988
size15,202
Jonathan Donaldson (jdon)

documentation

https://docs.rs/base32h

README

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
Commit count: 15

cargo fmt