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)) }