mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
add ppcrypto_test
This commit is contained in:
parent
fe806500e9
commit
b77738e619
47
pkg/utils/pcrypto/pcrypto_test.go
Normal file
47
pkg/utils/pcrypto/pcrypto_test.go
Normal file
@ -0,0 +1,47 @@
|
||||
package pcrypto
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_Encrypto(t *testing.T) {
|
||||
pp := new(Pcrypto)
|
||||
pp.Init([]byte("Hana"))
|
||||
res, err := pp.Encrypto([]byte("Just One Test!"))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
fmt.Printf("[%x]\n", res)
|
||||
}
|
||||
|
||||
func Test_Decrypto(t *testing.T) {
|
||||
pp := new(Pcrypto)
|
||||
pp.Init([]byte("Hana"))
|
||||
res, err := pp.Encrypto([]byte("Just One Test!"))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
res, err = pp.Decrypto(res)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
fmt.Printf("[%s]\n", string(res))
|
||||
}
|
||||
|
||||
func Test_PKCS7Padding(t *testing.T) {
|
||||
ltt := []byte("Test_PKCS7Padding")
|
||||
ltt = PKCS7Padding(ltt, aes.BlockSize)
|
||||
fmt.Printf("[%x]\n", (ltt))
|
||||
}
|
||||
|
||||
func Test_PKCS7UnPadding(t *testing.T) {
|
||||
ltt := []byte("Test_PKCS7Padding")
|
||||
ltt = PKCS7Padding(ltt, aes.BlockSize)
|
||||
ltt = PKCS7UnPadding(ltt)
|
||||
fmt.Printf("[%x]\n", ltt)
|
||||
}
|
Loading…
Reference in New Issue
Block a user