rspamd-base32 0.1.1

encodes and decodes base32 bug-to-bug compatible with Rspamd
Documentation
  • Coverage
  • 78.57%
    22 out of 28 items documented6 out of 14 items with examples
  • Size
  • Source code size: 54.09 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • vstakhov/rust-base32
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vstakhov

rust-base32

This is a conversion module from and to zbase32 encoding. It also supports RFC 4648 and Bech32 alphabets.

The main purpose of zbase32 is to provide human readable encoding that is more efficient than hex encoding. zbase32 utilizes up to len * 5 / 8 of space for encoded date and contains no padding (and hence no error control, like base64). However, it seems to be much readable for a human when an encoding does not contain padding.

Disclaimers

This module is intended to be compatible with Rspamd base32 encoding, so it has bug-to-bug compatibility with Rspamd C implementation including:

  • Zbase32 encodes data in reversed octets order (due to the initial bug in Rspamd and lack of test vectors)
  • RFC 4648 encoding does not include padding (because padding as defined in RFC for base32 is just ugly)

This is my first experiment with Rust, so many things might be ugly/broken.

Example


extern crate base32;

use base32::{encode, decode};

fn main() {
    let a = b"hello world";
    let b = "em3ags7py376g3tprd";

    assert_eq!(encode(a), b);
    assert_eq!(a, &decode(b).unwrap()[..]);
}

License

This project is licensed under Apache 2.0 license.