package ordercalc
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"encoding/hex"
|
|
"strings"
|
|
)
|
|
|
|
/**
|
|
* 通知订单状态时签名
|
|
* 签名方式:md5(order_sn-status--time---appid)
|
|
* 2020/08/21
|
|
*gz
|
|
*/
|
|
func Sign(order_sn, status, time, appid string) string {
|
|
return Md5Password(StringJoin(order_sn, "--", status, "--", time, "--", appid))
|
|
}
|
|
|
|
//密码加密
|
|
func Md5Password(password string) string {
|
|
h := md5.New()
|
|
h.Write([]byte(password)) // 需要加密的字符串
|
|
cipher2Str := h.Sum(nil)
|
|
sMd5 := hex.EncodeToString(cipher2Str) // 输出加密结果
|
|
return sMd5
|
|
}
|
|
|
|
/*
|
|
* 连接多个字符串
|
|
* 2019/05/05
|
|
*/
|
|
func StringJoin(s ...string) string {
|
|
var build strings.Builder
|
|
if len(s) > 0 {
|
|
for _, v := range s {
|
|
build.WriteString(v)
|
|
}
|
|
}
|
|
|
|
return build.String()
|
|
}
|