five8
five8 provides fast base58 encoding and decoding for 32-byte and 64-byte arrays.
It is a Rust port of fd_base58.
There are four functions in the public api:
encode_32encode_64decode_32decode_64
Examples
Encoding
let mut buf = ;
let bytes = &;
let len = encode_32;
assert_eq!;
assert_eq!;
Decoding
Benchmarks
These benchmarks were run on a laptop with AVX2 support. If your machine does not support AVX2 instructions it will be slower but should still be faster than the alternatives - see the second set of benchmarks where AVX2 is disabled.
AVX2 enabled (RUSTFLAGS='-C target-cpu-native)
| Benchmark | five8 | Lou-Kamades/fd_bs58 | bs58-rs |
|---|---|---|---|
| decode_32 | 36 ns | 88 ns | 291 ns |
| decode_64 | 124 ns | 203 ns | 1092 ns |
| encode_32 | 55 ns | 96 ns | 682 ns |
| encode_64 | 102 ns | 209 ns | 2781 ns |
AVX2 disabled (default RUSTFLAGS)
| Benchmark | five8 | Lou-Kamades/fd_bs58 | bs58-rs |
|---|---|---|---|
| decode_32 | 49 ns | 107 ns | 320 ns |
| decode_64 | 162 ns | 246 ns | 1176 ns |
| encode_32 | 86 ns | 98 ns | 824 ns |
| encode_64 | 179 ns | 219 ns | 3370 ns |
See Also
five8_const: compile-time base58 decoding.