diff --git a/src/box/box.go b/src/box/box.go index 96ea105..76c3f4c 100644 --- a/src/box/box.go +++ b/src/box/box.go @@ -23,7 +23,6 @@ func Bundle(payload interface{}, key []byte) (bundled string, err error) { return } } - // TODO: use base-122 encoding instead? https://github.com/kevinAlbs/Base122 bundled = base64.StdEncoding.EncodeToString(p) return } @@ -34,6 +33,7 @@ func Unbundle(bundled string, key []byte, payload interface{}) (err error) { if err != nil { return } + if key != nil { b, err = crypt.Decrypt(b, key) if err != nil { diff --git a/src/box/box_test.go b/src/box/box_test.go index 798be13..1d09bbd 100644 --- a/src/box/box_test.go +++ b/src/box/box_test.go @@ -1,6 +1,7 @@ package box import ( + "fmt" "testing" "github.com/schollz/croc/v7/src/crypt" @@ -33,6 +34,7 @@ func TestBox(t *testing.T) { bundled, err := Bundle(M{"hello, world"}, key) assert.Nil(t, err) + fmt.Println(bundled, len(bundled)) var m M err = Unbundle(bundled, key, &m)