mirror of
https://github.com/fatedier/frp.git
synced 2024-12-04 02:36:39 +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