package utils import ( "crypto/md5" "fmt" "sort" "strings" ) //请求参数签名校验 func GetSign(postData map[string]string) (sign string) { var keys []string for k, _ := range postData { if k != "sign" { keys = append(keys, k) } } //1,根据参数名称的ASCII码表的顺序排序 sort.Strings(keys) //2 根据排序后的参数名称,取出对应的值,并拼接字符串 var signStr string for _, v := range keys { signStr += v + "=" + postData[v] + "&" } sign = strings.ToUpper(fmt.Sprintf("%x", md5.Sum([]byte(signStr+"secret="+ReportSecret)))) return }