印度包网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.3 KiB

1 year ago
package base
import (
"server/util"
"strings"
"github.com/liangdas/mqant/log"
1 year ago
)
func (b *Base) SignMD5(send interface{}, pass ...string) string {
signStr := GetSignStr(send, pass...)
if b.KeyName == "" {
signStr += "&key=" + b.SignKey
} else {
signStr += "&" + b.KeyName + "=" + b.SignKey
}
1 year ago
ret := util.CalculateMD5(signStr)
if b.ShouldSignUpper {
ret = strings.ToUpper(ret)
}
log.Info("SignStr:%v,SignMD5:%v", signStr, ret)
1 year ago
return ret
}
2 months ago
func (b *Base) SignMD5WithStr(str string) string {
signStr := GetSignStrNull(str, b.SignPassStr...)
if b.PassKeyName {
signStr += b.SignKey
} else if b.KeyName == "" {
signStr += "&key=" + b.SignKey
} else {
signStr += "&" + b.KeyName + "=" + b.SignKey
}
log.Debug("final signStr:%s", signStr)
ret := util.CalculateMD5(signStr)
if b.ShouldSignUpper {
ret = strings.ToUpper(ret)
}
return ret
}
func (b *Base) SignMD5WithStrEmpty(str string) string {
signStr := GetSignWithStrEmpty(str, b.SignPassStr...)
if b.PassKeyName {
signStr += b.SignKey
} else if b.KeyName == "" {
signStr += "&key=" + b.SignKey
} else {
signStr += "&" + b.KeyName + "=" + b.SignKey
}
log.Debug("final signStr:%s", signStr)
ret := util.CalculateMD5(signStr)
if b.ShouldSignUpper {
ret = strings.ToUpper(ret)
}
return ret
}