From f3e31fe7958fe8b7f6ac50126cb43298d8029d25 Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Wed, 28 Jan 2015 15:27:59 -0800 Subject: [PATCH] Fixing build break --- pkg/utils/crypto/keys/keys.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/utils/crypto/keys/keys.go b/pkg/utils/crypto/keys/keys.go index 961bcbe42..f6985ef79 100644 --- a/pkg/utils/crypto/keys/keys.go +++ b/pkg/utils/crypto/keys/keys.go @@ -1,7 +1,10 @@ package keys import ( + "bufio" + "bytes" "crypto/rand" + "encoding/base64" ) var alphaNumericTable = []byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") @@ -34,13 +37,16 @@ func GetRandomAlphaNumericFull(size int) ([]byte, error) { func GetRandomBase64(size int) ([]byte, error) { rb := make([]byte, size) - n, err := rand.Read(rb) + _, err := rand.Read(rb) if err != nil { return nil, err } - dest := make([]byte, n) - base64.URLEncoding.EncodeTo(dest, rb) - return dest, nil + var bytesBuffer bytes.Buffer + writer := bufio.NewWriter(&bytesBuffer) + encoder := base64.NewEncoder(base64.StdEncoding, writer) + encoder.Write(rb) + encoder.Close() + return bytesBuffer.Bytes(), nil } func ValidateAccessKey(key []byte) bool {