base58

package module
v0.0.0-...-6237cf6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2015 License: ISC Imports: 2 Imported by: 164 modules, 219 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-base58

I extracted this package from https://github.com/conformal/btcutil to provide a simple base58 package that

  • defaults to base58-check (btc)
  • and allows using different alphabets.

Usage

package main

import (
  "fmt"
  b58 "github.com/jbenet/go-base58"
)

func main() {
  buf := []byte{255, 254, 253, 252}
  fmt.Printf("buffer: %v\n", buf)

  str := b58.Encode(buf)
  fmt.Printf("encoded: %s\n", str)

  buf2 := b58.Decode(str)
  fmt.Printf("decoded: %v\n", buf2)
}
Another alphabet
package main

import (
  "fmt"
  b58 "github.com/jbenet/go-base58"
)

const BogusAlphabet = "ZYXWVUTSRQPNMLKJHGFEDCBAzyxwvutsrqponmkjihgfedcba987654321"


func encdec(alphabet string) {
  fmt.Printf("using: %s\n", alphabet)

  buf := []byte{255, 254, 253, 252}
  fmt.Printf("buffer: %v\n", buf)

  str := b58.EncodeAlphabet(buf, alphabet)
  fmt.Printf("encoded: %s\n", str)

  buf2 := b58.DecodeAlphabet(str, alphabet)
  fmt.Printf("decoded: %v\n\n", buf2)
}


func main() {
  encdec(b58.BTCAlphabet)
  encdec(b58.FlickrAlphabet)
  encdec(BogusAlphabet)
}

License

Package base58 (and the original btcutil) are licensed under the ISC License.

Documentation

Overview

Package base58 provides base58-check encoding. The alphabet is modifyiable for

Base58 Usage

To decode a base58 string:

rawData := base58.Base58Decode(encodedData)

Similarly, to encode the same data:

encodedData := base58.Base58Encode(rawData)

Index

Constants

View Source
const BTCAlphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

alphabet is the modified base58 alphabet used by Bitcoin.

View Source
const FlickrAlphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"

Variables

This section is empty.

Functions

func Decode

func Decode(b string) []byte

Decode decodes a modified base58 string to a byte slice, using BTCAlphabet

func DecodeAlphabet

func DecodeAlphabet(b, alphabet string) []byte

DecodeAlphabet decodes a modified base58 string to a byte slice, using alphabet.

func Encode

func Encode(b []byte) string

Encode encodes a byte slice to a modified base58 string, using BTCAlphabet

func EncodeAlphabet

func EncodeAlphabet(b []byte, alphabet string) string

Encode encodes a byte slice to a modified base58 string, using alphabet

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL