Documentation ¶
Overview ¶
Package basen basen (base-N) is a simple Go encoding package for representing bytes as big integers in arbitrary base-N encoding.
Index ¶
- Variables
- type Encoding
- func (enc *Encoding) Base() int
- func (enc *Encoding) DecodeString(s string) ([]byte, error)
- func (enc *Encoding) DecodeStringN(s string, n int) ([]byte, error)
- func (enc *Encoding) EncodeToString(b []byte) string
- func (enc *Encoding) MustRandom(n int) string
- func (enc *Encoding) Random(n int) (string, error)
Constants ¶
This section is empty.
Variables ¶
var Base58 = NewEncoding(base58Alphabet)
Base58 represents bytes as a base-58 number [1-9A-GHJ-LM-Za-z].
var Base62 = NewEncoding(base62Alphabet)
Base62 represents bytes as a base-62 number [0-9A-Za-z].
Functions ¶
This section is empty.
Types ¶
type Encoding ¶
type Encoding struct {
// contains filtered or unexported fields
}
Encoding represents a given base-N encoding.
func NewEncoding ¶
NewEncoding creates a new base-N representation from the given alphabet. Panics if the alphabet is not unique. Only ASCII characters are supported.
func (*Encoding) DecodeString ¶
DecodeString returns the bytes for the given base-encoded string.
func (*Encoding) DecodeStringN ¶
DecodeStringN returns N bytes for the given base-encoded string. Use this method to ensure the value is left-padded with zeroes.
func (*Encoding) EncodeToString ¶
EncodeToString returns the base-encoded string representation of the given bytes.
func (*Encoding) MustRandom ¶
MustRandom returns the base-encoded representation of n random bytes, panicking in the unlikely event of a read error from the random source.