Crate bs58

source ·
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.


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


§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")
let encoded = bs58::encode(decoded)
assert_eq!("4DSSNaN1SC", encoded);

§Decoding into an existing buffer

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


  • Support for configurable alphabets
  • Functions for decoding Base58 encoded strings.
  • Functions for encoding into Base58 encoded strings.