123456789101112131415161718192021222324 |
- package util
- import (
- "bytes"
- "testing"
- )
- // TestAES test
- func TestAES(t *testing.T) {
- var bb bytes.Buffer
- for bb.Len() < 1024 {
- bb.Write([]byte("this is a very long text. "))
- }
- b := bb.Bytes()
- t.Logf("DATA %v %s", len(b), string(b))
- key := KeyAES()
- x := EncryptAES(key, b)
- t.Logf("ENC LEN %v", len(x))
- p := DecryptAES(key, x)
- t.Logf("PLAIN %v %s", len(p), string(p))
- if !bytes.Equal(b, p) {
- t.Errorf("ERROR\n%s\n%s", string(b), string(p))
- }
- }
|