Skip to content
forked from mr-tron/base58

Fast implementation of base58 encoding on golang.

License

Notifications You must be signed in to change notification settings

Stebalien/base58

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

base58 A Fast Implementation of Base58 encoding used in Bitcoin

Fast implementation of base58 encoding in Go (Golang).

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

To import library

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

Example

package main

import (
	"fmt"
	"os"

	"github.com/mr-tron/base58/base58"
)

func main() {

	exampleBase58Encoded := []string{
		"1QCaxc8hutpdZ62iKZsn1TCG3nh7uPZojq",
		"1DhRmSGnhPjUaVPAj48zgPV9e2oRhAQFUb",
		"17LN2oPYRYsXS9TdYdXCCDvF2FegshLDU2",
		"14h2bDLZSuvRFhUL45VjPHJcW667mmRAAn",
	}

	// If a base58 string is on the command line, then use that instead of the 4 exampels above.
	if len(os.Args) > 1 {
		exampleBase58Encoded = os.Args[1:]
	}

	for _, vv := range exampleBase58Encoded {
		num, err := base58.Decode(vv)
		if err != nil {
			fmt.Printf("Demo %d, got error %s\n", err)
			continue
		}
		chk := base58.Encode(num)
		if vv == string(chk) {
			fmt.Printf ( "Successfully decoded then re-encoded %s\n", vv )
		} else {
			fmt.Printf ( "Failed on %s\n", vv )
		}
	}
}

About

Fast implementation of base58 encoding on golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%