From a7ad774644588ae3e52ff60bd5e2365beb13c662 Mon Sep 17 00:00:00 2001 From: Shelly Wei Date: Mon, 2 Dec 2019 16:57:30 -0800 Subject: [PATCH] add test --- crypto/crypto_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index f37b30d..b09e4ff 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -8,6 +8,7 @@ import ( const ( KeyString = "CAISIJFNZZd5ZSvi9OlJP/mz/vvUobvlrr2//QN4DzX/EShP" + EncryptKey = "Tron2theMoon1234" ) func TestSignVerify(t *testing.T) { @@ -44,3 +45,13 @@ func TestSignVerify(t *testing.T) { t.Error("Verify with public key failed") } } + +func TestEncryptDecrypt(t *testing.T) { + origin := "Hello World" + key := []byte(EncryptKey) + encryptMsg, _ := Encrypt(key, []byte(origin)) + msg, _ := Decrypt(key, []byte(encryptMsg)) + if string(msg) != origin { + t.Errorf("Decrypt failed") + } +}