From 1fb242308d4c46d3ee7e0d93c4447e7d6b2d68d7 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Tue, 12 Nov 2019 14:31:15 -0800 Subject: [PATCH] don't use 65534 --- src/box/box.go | 2 +- src/box/box_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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)