transfer_middleware/until/common/zltx.go

30 lines
601 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package common
import (
"fmt"
"sort"
"strings"
)
func ZltxSign(postData map[string]interface{}, secret string) string {
// 第一步把key升序
keys := make([]string, 0, len(postData))
for key := range postData {
keys = append(keys, key)
}
sort.Strings(keys)
// 第二步:生成签名
// 拼接用于生成签名的原始字符串
rawStr := ""
for _, key := range keys {
value := fmt.Sprintf("%v", postData[key])
if rawStr != "" {
rawStr += "&"
}
rawStr += fmt.Sprintf("%s=%s", key, value)
}
rawStr += "&key=" + secret
return strings.ToUpper(GetMD5Hash(rawStr))
}