1 # Fast Implementation of Base58 encoding
2 [![GoDoc](https://godoc.org/github.com/mr-tron/base58?status.svg)](https://godoc.org/github.com/mr-tron/base58) [![Go Report Card](https://goreportcard.com/badge/github.com/mr-tron/base58)](https://goreportcard.com/report/github.com/mr-tron/base58)
3 [![Used By](https://sourcegraph.com/github.com/mr-tron/base58/base58/-/badge.svg)](https://sourcegraph.com/github.com/mr-tron/base58?badge)
5 Fast implementation of base58 encoding in Go.
7 Base algorithm is copied from https://github.com/trezor/trezor-crypto/blob/master/base58.c
10 Trivial - encoding via big.Int (over libraries use this implemenation)
11 Fast - optimized algorythm from trezor
14 BenchmarkTrivialBase58Encoding-4 200000 10602 ns/op
15 BenchmarkFastBase58Encoding-4 1000000 1637 ns/op
16 BenchmarkTrivialBase58Decoding-4 200000 8316 ns/op
17 BenchmarkFastBase58Decoding-4 1000000 1045 ns/op
19 Encoding - **faster by 6 times**
21 Decoding - **faster by 8 times**
31 "github.com/mr-tron/base58"
36 encoded := "1QCaxc8hutpdZ62iKZsn1TCG3nh7uPZojq"
37 num, err := base58.Decode(encoded)
39 fmt.Printf("Demo %v, got error %s\n", encoded, err)
41 chk := base58.Encode(num)
42 if encoded == string(chk) {
43 fmt.Printf ( "Successfully decoded then re-encoded %s\n", encoded )