22 lines
429 B
Go
22 lines
429 B
Go
package utils
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestCrypt(t *testing.T) {
|
|
aesKey := []byte("123456789012345678901234567890ab")
|
|
msg := "hellasfsafsdsads"
|
|
encryptedMsg, err := AESCBCEncpryt([]byte(msg), aesKey, aesKey[:16])
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
decryptedMsg, err := AESCBCDecpryt(encryptedMsg, aesKey, aesKey[:16])
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if msg != string(decryptedMsg) {
|
|
t.Fatal("result is wrong")
|
|
}
|
|
}
|