Use base64-encoding in favor of hex-encoding

This commit is contained in:
Norman Soetbeer 2020-09-07 08:52:42 +02:00
parent 0273362499
commit 7a865c80b8
1 changed files with 4 additions and 4 deletions

View File

@ -3,15 +3,15 @@ package embed
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"encoding/hex" "encoding/base64"
"io" "io"
"github.com/markbates/pkger/here" "github.com/markbates/pkger/here"
) )
func Decode(src []byte) ([]byte, error) { func Decode(src []byte) ([]byte, error) {
dst := make([]byte, hex.DecodedLen(len(src))) dst := make([]byte, base64.RawStdEncoding.DecodedLen(len(src)))
_, err := hex.Decode(dst, src) _, err := base64.RawStdEncoding.Decode(dst, src)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -44,7 +44,7 @@ func Encode(b []byte) ([]byte, error) {
return nil, err return nil, err
} }
s := hex.EncodeToString(bb.Bytes()) s := base64.RawStdEncoding.EncodeToString(bb.Bytes())
return []byte(s), nil return []byte(s), nil
} }