Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 500713b

Browse files
committed
Test AESEncrypt
1 parent 4135dba commit 500713b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

string_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,30 @@ import (
1818
"testing"
1919

2020
. "github.com/smartystreets/goconvey/convey"
21+
"crypto/rand"
2122
)
2223

24+
func TestAESEncrypt(t *testing.T) {
25+
key := make([]byte, 16) // AES-128
26+
_, err := rand.Read(key)
27+
if err != nil {
28+
t.Fatal("Failed to create 128 bit AES key: " + err.Error())
29+
}
30+
31+
nonce := make([]byte, 12)
32+
_, err = rand.Read(nonce)
33+
if err != nil {
34+
t.Fatal("Failed to create 12 byte nonce: " + err.Error())
35+
}
36+
37+
plaintext := "this will be encrypted"
38+
39+
_, err := AESEncrypt(key, nonce, plaintext)
40+
if err != nil {
41+
t.Fatal("Failed to encrypt plaintext: " + err.Error())
42+
}
43+
}
44+
2345
func TestIsLetter(t *testing.T) {
2446
if IsLetter('1') {
2547
t.Errorf("IsLetter:\n Expect => %v\n Got => %v\n", false, true)

0 commit comments

Comments
 (0)