Crate bs58[][src]

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.

Features

FeatureActivationEffect
stdon-by-defaultImplement Error for error types
allocimplied by stdSupport encoding/decoding to Vec and String as appropriate
checkoff-by-defaultIntegrated support for Base58Check

Examples

Basic example

let decoded = bs58::decode("he11owor1d").into_vec()?;
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()?;
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)?;
bs58::encode(decoded).into(&mut encoded)?;
assert_eq!("he11owor1d", encoded);

Modules

alphabet

Support for configurable alphabets

decode

Functions for decoding Base58 encoded strings.

encode

Functions for encoding into Base58 encoded strings.

Structs

Alphabet

Prepared Alphabet for EncodeBuilder::with_alphabet and DecodeBuilder::with_alphabet.

Functions

decode

Setup decoder for the given string using the default alphabet.

encode

Setup encoder for the given bytes using the default alphabet.