z-base-32

ci

The z-base-32 is a human oriented base32 encoding.

API

The library exposes two functions with following signatures and error type:

```rs pub fn encode(input: &[u8]) -> String;

pub fn decode(input: &str) -> Result, DecodeError>;

pub struct DecodeError; ```

Example

```rs use zbase32::{encode, decode};

fn main() { asserteq!(encode(b"foo"), "c3zs6".tostring()); asserteq!(Ok(b"foo"), decode("c3zs6".tostring())); assert_eq!(decode(&encode(b"foo")).unwrap(), b"foo") } ```

Python

Building

This crate can be compiled with feature flag python in which case it produces python bindings. To build a Python wheels use maturin:

console maturin build --cargo-extra-args="--features python"

API

```py def encode(input: bytes) -> str:

def decode(input: str) -> bytes:

class DecodeError(Exception): ```

Example

```py import zbase32

assert zbase32.encode(b'foo') == 'c3zs6'

assert zbase32.decode('c3zs6') == b'foo'

try: zbase32.decode('invalid@char') except zbase32.DecodeError as e: print(e) ```

References