mr-tron/base58

Fast implementation of base58 encoding on golang.

189

stars

80

commits

Go

primary language

Apr 4, 2026

updated

base58
encoding
fast
golang

README

Fast Implementation of Base58 encoding

GoDoc Go Report Card Used By

Fast implementation of base58 encoding in Go.

Base algorithm is adapted from https://github.com/trezor/trezor-crypto/blob/master/base58.c

Benchmark

  • Trivial - encoding based on big.Int (most libraries use such an implementation)
  • Fast - optimized algorithm provided by this module
cpu: Apple M4
BenchmarkTrivialBase58Encoding-10       	  712528	      1539 ns/op
BenchmarkFastBase58Encoding-10          	 6090552	       193.7 ns/op

BenchmarkTrivialBase58Decoding-10       	 1539550	       767.5 ns/op
BenchmarkFastBase58Decoding-10          	18001034	        64.68 ns/op

cpu: AMD Ryzen 7 PRO 4750U
BenchmarkTrivialBase58Encoding-16                 239527              5149 ns/op
BenchmarkFastBase58Encoding-16                   5029388               252.6 ns/op

BenchmarkTrivialBase58Decoding-16                 880732              1434 ns/op
BenchmarkFastBase58Decoding-16                   9524245               151.9 ns/op

Encoding - faster by 8 times

Decoding - faster by 12 times

Usage example


package main

import (
	"fmt"
	"github.com/mr-tron/base58"
)

func main() {

	encoded := "1QCaxc8hutpdZ62iKZsn1TCG3nh7uPZojq"
	num, err := base58.Decode(encoded)
	if err != nil {
		fmt.Printf("Demo %v, got error %s\n", encoded, err)	
	}
	chk := base58.Encode(num)
	if encoded == string(chk) {
		fmt.Printf ( "Successfully decoded then re-encoded %s\n", encoded )
	} 
}

Contributors

mr-tron

46 commits

Stebalien

16 commits

ribasushi

12 commits

pschlump

5 commits

mr-tron/base58

Fast implementation of base58 encoding on golang.

189

stars

80

commits

Go

primary language

Apr 4, 2026

updated

base58
encoding
fast
golang

README

Fast Implementation of Base58 encoding

GoDoc Go Report Card Used By

Fast implementation of base58 encoding in Go.

Base algorithm is adapted from https://github.com/trezor/trezor-crypto/blob/master/base58.c

Benchmark

  • Trivial - encoding based on big.Int (most libraries use such an implementation)
  • Fast - optimized algorithm provided by this module
cpu: Apple M4
BenchmarkTrivialBase58Encoding-10       	  712528	      1539 ns/op
BenchmarkFastBase58Encoding-10          	 6090552	       193.7 ns/op

BenchmarkTrivialBase58Decoding-10       	 1539550	       767.5 ns/op
BenchmarkFastBase58Decoding-10          	18001034	        64.68 ns/op

cpu: AMD Ryzen 7 PRO 4750U
BenchmarkTrivialBase58Encoding-16                 239527              5149 ns/op
BenchmarkFastBase58Encoding-16                   5029388               252.6 ns/op

BenchmarkTrivialBase58Decoding-16                 880732              1434 ns/op
BenchmarkFastBase58Decoding-16                   9524245               151.9 ns/op

Encoding - faster by 8 times

Decoding - faster by 12 times

Usage example


package main

import (
	"fmt"
	"github.com/mr-tron/base58"
)

func main() {

	encoded := "1QCaxc8hutpdZ62iKZsn1TCG3nh7uPZojq"
	num, err := base58.Decode(encoded)
	if err != nil {
		fmt.Printf("Demo %v, got error %s\n", encoded, err)	
	}
	chk := base58.Encode(num)
	if encoded == string(chk) {
		fmt.Printf ( "Successfully decoded then re-encoded %s\n", encoded )
	} 
}

Contributors

mr-tron

46 commits

Stebalien

16 commits

ribasushi

12 commits

pschlump

5 commits

Languages

Go

100.0%