mirror of
https://git.oceanpay.cc/danial/kami_script.git
synced 2025-12-18 20:56:47 +00:00
40 lines
780 B
Go
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)
|
|
}
|