Files
kami_script/models/order.go
sunxiaolong b36783ac34 初次提交
2023-12-10 22:39:16 +08:00

40 lines
780 B
Go

package models
import (
"encoding/hex"
"encoding/json"
"kami_scripts/utils"
"time"
)
type OrderParams struct {
PayKey string `json:"payKey"` // 支付明文秘钥
GeneratedTime time.Time `json:"generatedTime"` // 过期时间
Duration int `json:"duration"` // 存续时间(小时)
}
func (p *OrderParams) Encrypt() string {
prepareData := p.String()
if prepareData == "" {
return prepareData
}
// 加密密码数据
key := "thisis32bitlongpassphraseimusing"
iv := "1234567890123456"
result, _ := utils.AesCBCEncrypt([]byte(prepareData), []byte(key), []byte(iv))
return hex.EncodeToString(result)
}
func (p *OrderParams) String() string {
r, err := json.Marshal(p)
if err != nil {
return ""
}
return string(r)
}