base58

package
v0.0.0-...-b31a8eb Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package base58 implements base58 encoding.

It pre-defines encoding alphabets as used by Bitcoin and Ripple addresses as well as for Flickr short URLs.

Base58 is not a computationaly efficient encoding. Unless you have a need for compaitbility with a pre-existing scheme (e.g. Bitcoin, Ripple, or Flickr) then use another encoding such as base32 or base64. Under no circumstances should base58 be considered where the encoded data is of arbitrary size; encoding/decoding data of length n is ~O(n²).

Index

Constants

This section is empty.

Variables

View Source
var Bitcoin = New("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")

Bitcoin is the encoding scheme used for Bitcoin addresses.

View Source
var Flickr = New("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")

Flickr is the encoding scheme used for Flickr's short URLs.

View Source
var Ripple = New("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz")

Ripple is the encoding scheme used for Ripple addresses.

Functions

This section is empty.

Types

type CorruptInputError

type CorruptInputError int

A CorruptInputError is reported for invalid base58 input.

func (CorruptInputError) Error

func (e CorruptInputError) Error() string

type Encoding

type Encoding struct {
	// contains filtered or unexported fields
}

func New

func New(encoder string) *Encoding

New returns a new Encoding defined by the given alphabet, which must be a 58-byte string.

func (*Encoding) AppendDecode

func (enc *Encoding) AppendDecode(dst, src []byte) ([]byte, error)

AppendDecode appends the decoded value of the base58 encoded src to dst and returns the extended buffer.

AppendDecode returns CorruptInputError if src contains characters outside the encoding alphabet.

func (*Encoding) AppendDecodeString

func (enc *Encoding) AppendDecodeString(dst []byte, s string) ([]byte, error)

AppendDecodeString appends the decoded value of the base58 encoded s to dst and returns the extended buffer.

AppendDecodeString returns CorruptInputError if s contains characters outside the encoding alphabet.

func (*Encoding) AppendEncode

func (enc *Encoding) AppendEncode(dst, src []byte) []byte

AppendEncode appends the base58 encoding of src to dst and returns the extended buffer.

func (*Encoding) EncodeToString

func (enc *Encoding) EncodeToString(src []byte) string

EncodeToString returns the base58 encoding of src.

Jump to

Keyboard shortcuts

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