goext/cryptext/aes_test.go

37 lines
564 B
Go
Raw Permalink Normal View History

2023-01-29 06:02:58 +01:00
package cryptext
2023-02-03 00:59:54 +01:00
import (
"fmt"
2023-03-31 13:33:06 +02:00
"gogs.mikescher.com/BlackForestBytes/goext/tst"
2023-02-03 00:59:54 +01:00
"testing"
)
2023-01-29 06:02:58 +01:00
func TestEncryptAESSimple(t *testing.T) {
pw := []byte("hunter12")
str1 := []byte("Hello World")
2023-02-03 00:59:54 +01:00
str2, err := EncryptAESSimple(pw, str1, 512)
2023-01-29 06:02:58 +01:00
if err != nil {
panic(err)
}
2023-02-03 00:59:54 +01:00
fmt.Printf("%s\n", str2)
2023-01-29 06:02:58 +01:00
str3, err := DecryptAESSimple(pw, str2)
if err != nil {
panic(err)
}
2023-03-31 13:33:06 +02:00
tst.AssertEqual(t, string(str1), string(str3))
2023-02-03 00:59:54 +01:00
str4, err := EncryptAESSimple(pw, str3, 512)
if err != nil {
panic(err)
}
2023-03-31 13:33:06 +02:00
tst.AssertNotEqual(t, string(str2), string(str4))
2023-02-03 00:59:54 +01:00
2023-01-29 06:02:58 +01:00
}