Expand description
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
Feature | Activation | Effect |
---|---|---|
std | on-by-default | Implement Error for error types |
alloc | implied by std | Support encoding/decoding to Vec and String as appropriate |
check | off-by-default | Integrated 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
Support for configurable alphabets
Functions for decoding Base58 encoded strings.
Functions for encoding into Base58 encoded strings.
Structs
Prepared Alphabet for
EncodeBuilder::with_alphabet
and
DecodeBuilder::with_alphabet
.
Functions
Setup decoder for the given string using the default alphabet.
Setup encoder for the given bytes using the default alphabet.