package nebula import ( "bytes" "errors" "fmt" "github.com/jxskiss/base62" ) func encodeWithPrefix(prefix []byte, b []byte) []byte { res := make([]byte, 0, len(prefix)+len(b)*4) res = append(res, prefix...) res = base62.EncodeToBuf(res, b) return res } func decodeWithPrefix(prefix []byte, b []byte) ([]byte, error) { if len(b) < len(prefix) { return nil, errors.New("input is too short") } else if !bytes.HasPrefix(b, prefix) { return nil, fmt.Errorf("missing expected prefix %q", prefix) } return base62.Decode(b[len(prefix):]) }