Documentation ¶
Overview ¶
Package base62 implements base62 encoding
Index ¶
- Variables
- func NewDecoder(enc *Encoding, r io.Reader) io.Reader
- func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser
- type CorruptInputError
- type Encoding
- func (enc *Encoding) Decode(dst, src []byte) (n int, err error)
- func (enc *Encoding) DecodeString(s string) ([]byte, error)
- func (enc *Encoding) DecodedLen(n int) int
- func (enc *Encoding) Encode(dst, src []byte)
- func (enc *Encoding) EncodeToString(src []byte) string
- func (enc *Encoding) EncodedLen(n int) int
Constants ¶
This section is empty.
Variables ¶
var StdEncoding = NewEncoding(encodeStd)
Functions ¶
func NewDecoder ¶
NewDecoder constructs a new base62 stream decoder.
func NewEncoder ¶
func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser
NewEncoder returns a new base62 stream encoder. Data written to the returned writer will be encoded using enc and then written to w. Base62 encodings operate in 4-byte blocks; when finished writing, the caller must Close the returned encoder to flush any partially written blocks.
Types ¶
type CorruptInputError ¶
type CorruptInputError error
type Encoding ¶
type Encoding struct {
// contains filtered or unexported fields
}
Encodings
func NewEncoding ¶
NewEncoding returns a new Encoding defined by the given alphabet, which must be a 62-byte string.
func (*Encoding) Decode ¶
Decode decodes src using the encoding enc. It writes at most DecodedLen(len(src)) bytes to dst and returns the number of bytes written. If src contains invalid base62 data, it will return the number of bytes successfully written and CorruptInputError.
func (*Encoding) DecodeString ¶
DecodeString returns the bytes represented by the base62 string s.
func (*Encoding) DecodedLen ¶
DecodedLen returns the maximum length in bytes of the decoded data corresponding to n bytes of base62-encoded data.
func (*Encoding) Encode ¶
Encode encodes src using the encoding enc, writing EncodedLen(len(src)) bytes to dst.
The encoding pads the output to a multiple of 4 bytes, so Encode is not appropriate for use on individual blocks of a large data stream. Use NewEncoder() instead.
func (*Encoding) EncodeToString ¶
EncodeToString returns the base62 encoding of src.
func (*Encoding) EncodedLen ¶
EncodedLen returns the length in bytes of the base62 encoding of an input buffer of length n.