55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package quick_recharge
|
|
|
|
import (
|
|
"fmt"
|
|
"git.rosy.net.cn/baseapi"
|
|
"go.uber.org/zap"
|
|
"testing"
|
|
)
|
|
|
|
var (
|
|
api *API
|
|
sugarLogger *zap.SugaredLogger
|
|
)
|
|
|
|
func init() {
|
|
logger, _ := zap.NewDevelopment()
|
|
sugarLogger = logger.Sugar()
|
|
baseapi.Init(sugarLogger)
|
|
|
|
api = New(AppKey, UserID)
|
|
}
|
|
|
|
func TestAes(t *testing.T) {
|
|
|
|
key := []byte("5fb9600dd400b5e0853caed93ebbfb4e") // 256 位密钥,必须是 32 字节长
|
|
plaintext := []byte("mpwZ8Mf03eQm0xAu7+RWG8VM5RQpSIBrqUGilYts6p1c04uydMlsM5z85Azgt8HORVbJv+EReLAxoaHW2L8ZWeyG80mskqzjyKr8wuOiv/6upkYGi0lAVTSfrxuJaf")
|
|
|
|
// 加密
|
|
encryptedText, err := AESEncrypt(plaintext, key)
|
|
if err != nil {
|
|
fmt.Println("Encryption failed:", err)
|
|
return
|
|
}
|
|
fmt.Println("Encrypted Text:", encryptedText)
|
|
|
|
}
|
|
|
|
func TestAESDecrypt(t *testing.T) {
|
|
encryptedText := "mpwZ8Mf031teQm0xAu7+RWG8VM5RQpSIBrqUGilYts6p1c04uydMlsM5z85Azgt8HORVbJv+EReLAxoaHW2L8ZWeyG80mskqzjyKr8wuOiv/6upkYGi0lAVTSfrxuJaf"
|
|
key := "5fb9600dd400b5e0853caed93ebbfb4e"
|
|
// 解密
|
|
decryptedText, err := AESDecrypt([]byte(encryptedText), []byte(key))
|
|
if err != nil {
|
|
fmt.Println("Decryption failed:", err)
|
|
return
|
|
}
|
|
fmt.Println("Decrypted Text:", decryptedText)
|
|
|
|
}
|
|
|
|
func TestSign(t *testing.T) {
|
|
md5 := api.Md5Sign(AppKey, UserID)
|
|
fmt.Println(md5)
|
|
}
|