[][src]Crate bs58

Another Base58 codec implementation.

Compared to base58 this is significantly faster at decoding (about 2.4x as fast when decoding 32 bytes), almost the same speed for encoding (about 3% slower when encoding 32 bytes) and doesn't have the 128 byte limitation.

Compared to rust-base58 this is massively faster (over ten times as fast when decoding 32 bytes, almost 40 times as fast when encoding 32 bytes) and has no external dependencies.

Compared to both this supports a configurable alphabet and user provided buffers for zero-allocation {en,de}coding.

Optional Features

check (off-by-default)

Integrated support for Base58Check, this allows automatically calculating the checksum during encoding and verifying during decoding.

Examples

Basic example

let decoded = bs58::decode("he11owor1d").into_vec().unwrap();
let encoded = bs58::encode(decoded).into_string();
assert_eq!("he11owor1d", encoded);

Changing the alphabet

let decoded = bs58::decode("he11owor1d")
    .with_alphabet(bs58::alphabet::RIPPLE)
    .into_vec()
    .unwrap();
let encoded = bs58::encode(decoded)
    .with_alphabet(bs58::alphabet::FLICKR)
    .into_string();
assert_eq!("4DSSNaN1SC", encoded);

Decoding into an existing buffer

let (mut decoded, mut encoded) = ([0xFF; 8], String::with_capacity(10));
bs58::decode("he11owor1d").into(&mut decoded).unwrap();
bs58::encode(decoded).into(&mut encoded);
assert_eq!("he11owor1d", encoded);

Modules

alphabet

Commonly used Base58 alphabets.

decode

Functions for decoding Base58 encoded strings.

encode

Functions for encoding into Base58 encoded strings.

Functions

decode

Setup decoder for the given string using the default alphabet.

encode

Setup encoder for the given bytes using the default alphabet.