-
Notifications
You must be signed in to change notification settings - Fork 1
/
aes_test.go
33 lines (30 loc) · 1.08 KB
/
aes_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package sse
import (
"fmt"
"testing"
)
func TestEncrypt(t *testing.T) {
key := []byte("1234567890123456") // 16 byte key
plaintext := []byte("somebody poisoned the waterhole!") // arbitrary length plaintext
ciphertext, err := Encrypt(plaintext, key)
if err != nil {
t.Errorf("%#v", err)
}
fmt.Printf("Input: %s, %x\n", string(plaintext), plaintext)
fmt.Printf("Output: %x\n", ciphertext)
}
func TestDecrypt(t *testing.T) {
key := []byte("1234567890123456") // 16 byte key
ciphertext := []byte{0xc8, 0xa0, 0x77, 0xe4, 0x18, 0xe3, 0x87, 0x36, 0x4b,
0xe2, 0xce, 0xc8, 0x44, 0xcc, 0xdc, 0x8, 0xc0, 0xd1, 0xe6, 0x2c, 0x47, 0x62,
0xf8, 0xd7, 0x52, 0x70, 0x32, 0x47, 0xb1, 0x2a, 0xbb, 0xb7, 0xc, 0x58, 0x81,
0x45, 0x4d, 0x86, 0xf2, 0xd6, 0x49, 0x17, 0x60, 0xfe, 0x45, 0x57, 0xa, 0x9b,
0x25, 0x4, 0x34, 0xb5, 0x3c, 0x75, 0xf8, 0xa1, 0x9, 0xb2, 0x8c, 0x8e, 0xe5,
0xec, 0x4e, 0x97}
plaintext, err := Decrypt(ciphertext, key)
if err != nil {
t.Errorf("%#v", err)
}
fmt.Printf("Input: %x\n", ciphertext)
fmt.Printf("Output: %x, %s\n", plaintext, string(plaintext))
}