base58

package
v0.0.0-...-6729ccb Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BTCAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")

BTCAlphabet is the bitcoin base58 alphabet.

View Source
var ErrChecksum = errors.New("checksum error")

ErrChecksum indicates that the checksum of a check-encoded string does not verify against the checksum.

View Source
var ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing")

ErrInvalidFormat indicates that the check-encoded string has an invalid format.

View Source
var FlickrAlphabet = NewAlphabet("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")

FlickrAlphabet is the flickr base58 alphabet.

Functions

func ChecksumFirst4Bytes

func ChecksumFirst4Bytes(data []byte, isNewCheckSum bool) (ckSum []byte)

ChecksumFirst4Bytes receives data in bytes array and returns a checksum which is 4 first bytes of hashing of data.

If isNewCheckSum, double SHA256 will be employed. Otherwise, single SHA3 will be employed.

func Decode

func Decode(str string) ([]byte, error)

Decode decodes the base58 encoded bytes.

func DecodeCheck

func DecodeCheck(input string) (result []byte, version byte, err error)

func Encode

func Encode(bin []byte) string

Encode encodes the passed bytes into a base58 encoded string.

func EncodeCheck

func EncodeCheck(input []byte) string

func FastBase58Decoding

func FastBase58Decoding(str string) ([]byte, error)

FastBase58Decoding decodes the base58 encoded bytes.

func FastBase58DecodingAlphabet

func FastBase58DecodingAlphabet(str string, alphabet *Alphabet) ([]byte, error)

FastBase58DecodingAlphabet decodes the base58 encoded bytes using the given b58 alphabet.

func FastBase58Encoding

func FastBase58Encoding(bin []byte) string

FastBase58Encoding encodes the passed bytes into a base58 encoded string.

func FastBase58EncodingAlphabet

func FastBase58EncodingAlphabet(bin []byte, alphabet *Alphabet) string

FastBase58EncodingAlphabet encodes the passed bytes into a base58 encoded string with the passed alphabet.

Types

type Alphabet

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

Alphabet is a a b58 alphabet.

func NewAlphabet

func NewAlphabet(s string) *Alphabet

NewAlphabet creates a new alphabet from the passed string.

It panics if the passed string is not 58 bytes long or isn't valid ASCII.

type Base58

type Base58 struct {
}

func (Base58) Decode

func (base58 Base58) Decode(b string) []byte

Decode decodes a modified base58 string to a byte slice.

func (Base58) Encode

func (base58 Base58) Encode(b []byte) string

Encode encodes a byte slice to a modified base58 string.

type Base58Check

type Base58Check struct {
}

func (Base58Check) Decode

func (self Base58Check) Decode(input string) (result []byte, version byte, err error)

Decode decodes a string that was encoded with Encode and verifies the checksum.

The Decode function allows to decode both old and new base58-encoded strings.

func (Base58Check) Encode

func (self Base58Check) Encode(input []byte, version byte) string

Encode prepends a version byte and appends a four byte checksum.

func (Base58Check) NewEncode

func (self Base58Check) NewEncode(input []byte, version byte) string

NewEncode prepends a version byte and appends a 4-byte checksum.

New way to generate the 4-byte checksum is applied to this function.

Jump to

Keyboard shortcuts

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