Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Repository files navigation

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 )
	} 
}

About

Fast implementation of base58 encoding on golang.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.