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.
57 lines
1.3 KiB
57 lines
1.3 KiB
package base |
|
|
|
import ( |
|
"server/util" |
|
"strings" |
|
|
|
"github.com/liangdas/mqant/log" |
|
) |
|
|
|
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 |
|
} |
|
ret := util.CalculateMD5(signStr) |
|
if b.ShouldSignUpper { |
|
ret = strings.ToUpper(ret) |
|
} |
|
log.Info("SignStr:%v,SignMD5:%v", signStr, ret) |
|
return ret |
|
} |
|
|
|
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 |
|
}
|
|
|