z-base-32: human-oriented base-32 encoding
Project description
z-base-32
The z-base-32
is a human oriented base32 encoding.
API
The library exposes two functions with following signatures and error type:
pub fn encode(input: &[u8]) -> String;
pub fn decode(input: &str) -> Result<Vec<u8>, DecodeError>;
pub struct DecodeError;
Example
use zbase32::{encode, decode};
fn main() {
assert_eq!(encode(b"foo"), "c3zs6".to_string());
assert_eq!(Ok(b"foo"), decode("c3zs6".to_string()));
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
:
maturin build --cargo-extra-args="--features python"
API
def encode(input: bytes) -> str:
def decode(input: str) -> bytes:
class DecodeError(Exception):
Example
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
z_base_32-0.1.0.tar.gz
(4.0 kB
view hashes)
Built Distributions
Close
Hashes for z_base_32-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16c89edf90cae388657cd8aa73d1e38c42413f366e0f45b6b828525aa81efc53 |
|
MD5 | f7fe199384f39841cad7ab48f7c5b43d |
|
BLAKE2b-256 | 605fdd5dfc5cf11aeaee4797791c7ef4b107d7fa37eb779b30e9bbeb3a891bb9 |
Close
Hashes for z_base_32-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdee2b55724b69e8043d5c390ec92498db23dd7e692681a7e1e04def6cc3e4fe |
|
MD5 | d6655ad1f11f72bf7bc499641a161b5c |
|
BLAKE2b-256 | fc609ef5a76e16d6419281138740c672601d3edc3d78fa2c2cecd9e9908eb554 |
Close
Hashes for z_base_32-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58afefd00a2471a24eaa0ad47ba72078bf1249b881e49c271a107d7601598e17 |
|
MD5 | 9b437f557825bb8e4a33e12e04cc699c |
|
BLAKE2b-256 | c01891ae65da1c2e2e7349311f7ca2c1f554ab9877e360980af40e8d59feb93a |
Close
Hashes for z_base_32-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c43ed31b3a6b1d80b3204ddec36ac413ab37c3a152de61e7a98a51bb56eb0d7 |
|
MD5 | bab8468cdb3bb213fc9c6ccb4b3d46d7 |
|
BLAKE2b-256 | 71ae4f67ec0bf251b51b7b7c949eb8b740a3e83fff90b4ad590c007ce113e6d8 |