Files
EdgeNode/internal/utils/encrypt/method_aes_192_cfb_test.go

47 lines
874 B
Go
Raw Normal View History

2024-05-11 09:23:54 +08:00
package encrypt_test
2020-09-09 18:53:53 +08:00
import (
2024-05-11 09:23:54 +08:00
"github.com/TeaOSLab/EdgeNode/internal/utils/encrypt"
2020-09-09 18:53:53 +08:00
"runtime"
"strings"
"testing"
)
func TestAES192CFBMethod_Encrypt(t *testing.T) {
2024-05-11 09:23:54 +08:00
method, err := encrypt.NewMethodInstance("aes-192-cfb", "abc", "123")
2020-09-09 18:53:53 +08:00
if err != nil {
t.Fatal(err)
}
src := []byte("Hello, World")
dst, err := method.Encrypt(src)
if err != nil {
t.Fatal(err)
}
dst = dst[:len(src)]
t.Log("dst:", string(dst))
src, err = method.Decrypt(dst)
if err != nil {
t.Fatal(err)
}
t.Log("src:", string(src))
}
func BenchmarkAES192CFBMethod_Encrypt(b *testing.B) {
runtime.GOMAXPROCS(1)
2024-05-11 09:23:54 +08:00
method, err := encrypt.NewMethodInstance("aes-192-cfb", "abc", "123")
2020-09-09 18:53:53 +08:00
if err != nil {
b.Fatal(err)
}
2024-05-11 09:23:54 +08:00
var src = []byte(strings.Repeat("Hello", 1024))
2020-09-09 18:53:53 +08:00
for i := 0; i < b.N; i++ {
dst, err := method.Encrypt(src)
if err != nil {
b.Fatal(err)
}
_ = dst
}
}