1# basex 2-- 3 import "github.com/eknkc/basex" 4 5Package basex provides fast base encoding / decoding of any given alphabet using 6bitcoin style leading zero compression. It is a GO port of 7https://github.com/cryptocoinjs/base-x 8 9## Usage 10 11#### type Encoding 12 13```go 14type Encoding struct { 15} 16``` 17 18Encoding is a custom base encoding defined by an alphabet. It should bre created 19using NewEncoding function 20 21#### func NewEncoding 22 23```go 24func NewEncoding(alphabet string) (*Encoding, error) 25``` 26NewEncoding returns a custom base encoder defined by the alphabet string. The 27alphabet should contain non-repeating characters. Ordering is important. Example 28alphabets: 29 30 - base2: 01 31 - base16: 0123456789abcdef 32 - base32: 0123456789ABCDEFGHJKMNPQRSTVWXYZ 33 - base62: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 34 35#### func (*Encoding) Decode 36 37```go 38func (e *Encoding) Decode(source string) ([]byte, error) 39``` 40Decode function decodes a string previously obtained from Encode, using the same 41alphabet and returns a byte slice In case the input is not valid an arror will 42be returned 43 44#### func (*Encoding) Encode 45 46```go 47func (e *Encoding) Encode(source []byte) string 48``` 49Encode function receives a byte slice and encodes it to a string using the 50alphabet provided 51