mirror of
https://github.com/fatedier/frp.git
synced 2026-03-19 08:19:14 +08:00
utils/pcrypto: fix the bug of using aes
1. The aes IV needs to be unique, but not secure. 2. The key should be 16, 24 or 32 bytes. Fixes #85.
This commit is contained in:
@@ -24,7 +24,7 @@ var (
|
||||
|
||||
func init() {
|
||||
pp = &Pcrypto{}
|
||||
pp.Init([]byte("Hana"))
|
||||
pp.Init([]byte("12234567890123451223456789012345321:wq"))
|
||||
}
|
||||
|
||||
func TestEncrypt(t *testing.T) {
|
||||
@@ -60,3 +60,18 @@ func TestCompression(t *testing.T) {
|
||||
t.Fatalf("test compression error, from [%s] to [%s]", testStr, string(res))
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkEncrypt(b *testing.B) {
|
||||
testStr := "Test Encrypt!"
|
||||
for i := 0; i < b.N; i++ {
|
||||
pp.Encrypt([]byte(testStr))
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDecrypt(b *testing.B) {
|
||||
testStr := "Test Encrypt!"
|
||||
res, _ := pp.Encrypt([]byte(testStr))
|
||||
for i := 0; i < b.N; i++ {
|
||||
pp.Decrypt([]byte(res))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user