func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser {
	return &encoder{enc: enc, w: w}
}
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.
package base62
import (
	"errors"
	"fmt"
	"io"
)
type Encoding struct {
	encode    string
	decodeMap [256]byte
}
const encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789."  
func NewEncoding(encoder string) *Encoding {
	e := new(Encoding)
	e.encode = encoder
	for i := 0; i < len(e.decodeMap); i++ {
		e.decodeMap[i] = 0xFF
	}
	for i := 0; i < len(encoder); i++ {
		e.decodeMap[encoder[i]] = byte(i)
	}
	return e
}
var StdEncoding = NewEncoding(encodeStd)
func (enc *Encoding) Encode(dst, src []byte) {
	if len(src) == 0 {
		return
	}
	for len(src) > 0 {
		dst[0] = 0
		dst[1] = 0
		dst[2] = 0
		dst[3] = 0
		switch len(src) {
		default:
			dst[3] |= src[2] & 0x3F
			dst[2] |= src[2] >> 6
			fallthrough
		case 2:
			dst[2] |= (src[1] << 2) & 0x3F
			dst[1] |= src[1] >> 4
			fallthrough
		case 1:
			dst[1] |= (src[0] << 4) & 0x3F
			dst[0] |= src[0] >> 2
		}
		for j := 0; j < 4; j++ {
			dst[j] = enc.encode[dst[j]]
		}
		if len(src) < 3 {
			dst[3] = '+'
			if len(src) < 2 {
				dst[2] = '+'
			}
			break
		}
		src = src[3:]
		dst = dst[4:]
	}
}
func (enc *Encoding) EncodeToString(src []byte) string {
	buf := make([]byte, enc.EncodedLen(len(src)))
	enc.Encode(buf, src)
	return string(buf)
}
type encoder struct {
	err  error
	enc  *Encoding
	w    io.Writer
	buf  [3]byte     
	nbuf int         
	out  [1024]byte  
}
func (e *encoder) Write(p []byte) (n int, err error) {
	if e.err != nil {
		return 0, e.err
	}
	if e.nbuf > 0 {
		var i int
		for i = 0; i < len(p) && e.nbuf < 3; i++ {
			e.buf[e.nbuf] = p[i]
			e.nbuf++
		}
		n += i
		p = p[i:]
		if e.nbuf < 3 {
			return
		}
		e.enc.Encode(e.out[0:], e.buf[0:])
		if _, e.err = e.w.Write(e.out[0:4]); e.err != nil {
			return n, e.err
		}
		e.nbuf = 0
	}
	for len(p) >= 3 {
		nn := len(e.out) / 4 * 3
		if nn > len(p) {
			nn = len(p)
		}
		nn -= nn % 3
		if nn > 0 {
			e.enc.Encode(e.out[0:], p[0:nn])
			if _, e.err = e.w.Write(e.out[0 : nn/3*4]); e.err != nil {
				return n, e.err
			}
		}
		n += nn
		p = p[nn:]
	}
	for i := 0; i < len(p); i++ {
		e.buf[i] = p[i]
	}
	e.nbuf = len(p)
	n += len(p)
	return
}
func (e *encoder) Close() error {
	if e.err == nil && e.nbuf > 0 {
		e.enc.Encode(e.out[0:], e.buf[0:e.nbuf])
		e.nbuf = 0
		_, e.err = e.w.Write(e.out[0:4])
	}
	return e.err
}