frp/utils/pcrypto/pcrypto_test.go

48 lines
844 B
Go
Raw Normal View History

2016-02-03 11:46:12 +08:00
package pcrypto
import (
"crypto/aes"
"fmt"
"testing"
)
func TestEncrypto(t *testing.T) {
2016-02-03 11:46:12 +08:00
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 TestDecrypto(t *testing.T) {
2016-02-03 11:46:12 +08:00
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 TestPKCS7Padding(t *testing.T) {
2016-02-03 11:46:12 +08:00
ltt := []byte("Test_PKCS7Padding")
ltt = PKCS7Padding(ltt, aes.BlockSize)
fmt.Printf("[%x]\n", (ltt))
}
func TestPKCS7UnPadding(t *testing.T) {
2016-02-03 11:46:12 +08:00
ltt := []byte("Test_PKCS7Padding")
ltt = PKCS7Padding(ltt, aes.BlockSize)
ltt = PKCS7UnPadding(ltt)
fmt.Printf("[%x]\n", ltt)
}