| // Copyright 2011 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" |
| var bcEncoding = base64.NewEncoding(alphabet) |
| func base64Encode(src []byte) []byte { |
| n := bcEncoding.EncodedLen(len(src)) |
| bcEncoding.Encode(dst, src) |
| func base64Decode(src []byte) ([]byte, error) { |
| numOfEquals := 4 - (len(src) % 4) |
| for i := 0; i < numOfEquals; i++ { |
| dst := make([]byte, bcEncoding.DecodedLen(len(src))) |
| n, err := bcEncoding.Decode(dst, src) |