github.com/TeaOSLab/EdgeNode@v1.3.8/internal/encrypt/method_aes_192_cfb_test.go (about) 1 package encrypt 2 3 import ( 4 "runtime" 5 "strings" 6 "testing" 7 ) 8 9 func TestAES192CFBMethod_Encrypt(t *testing.T) { 10 method, err := NewMethodInstance("aes-192-cfb", "abc", "123") 11 if err != nil { 12 t.Fatal(err) 13 } 14 src := []byte("Hello, World") 15 dst, err := method.Encrypt(src) 16 if err != nil { 17 t.Fatal(err) 18 } 19 dst = dst[:len(src)] 20 t.Log("dst:", string(dst)) 21 22 src, err = method.Decrypt(dst) 23 if err != nil { 24 t.Fatal(err) 25 } 26 t.Log("src:", string(src)) 27 } 28 29 func BenchmarkAES192CFBMethod_Encrypt(b *testing.B) { 30 runtime.GOMAXPROCS(1) 31 32 method, err := NewMethodInstance("aes-192-cfb", "abc", "123") 33 if err != nil { 34 b.Fatal(err) 35 } 36 37 src := []byte(strings.Repeat("Hello", 1024)) 38 for i := 0; i < b.N; i++ { 39 dst, err := method.Encrypt(src) 40 if err != nil { 41 b.Fatal(err) 42 } 43 _ = dst 44 } 45 }