28 lines
482 B
Go
28 lines
482 B
Go
package auth
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestAES(t *testing.T) {
|
|
for _, plaintext := range []string{"", "payload!", "a really long payload here"} {
|
|
key := "password"
|
|
|
|
enc, err := encrypt(key, plaintext)
|
|
if err != nil {
|
|
t.Fatal("cannot enc:", err)
|
|
}
|
|
if enc == plaintext {
|
|
t.Fatal(enc)
|
|
}
|
|
|
|
dec, err := decrypt(key, enc)
|
|
if err != nil {
|
|
t.Fatal("cannot dec:", err)
|
|
}
|
|
if dec != plaintext {
|
|
t.Fatalf("want decrypted %q, got %q", plaintext, dec)
|
|
}
|
|
}
|
|
}
|