|
|
@ -134,13 +134,11 @@ func CmbHttpBuildQuery(data map[string]interface{}, filter_sign bool) string { |
|
|
|
|
|
|
|
build_str := strings.Trim(query, "&") |
|
|
|
|
|
|
|
log.Println("拼接后的数据: ", build_str) |
|
|
|
return build_str |
|
|
|
} |
|
|
|
|
|
|
|
// 生成签名sign--聚合支付
|
|
|
|
func SetSign(data map[string]interface{}, privateKey string) string { |
|
|
|
log.Println("招行加签start") |
|
|
|
build_str := CmbHttpBuildQuery(data, true) |
|
|
|
|
|
|
|
priv := new(sm2.PrivateKey) |
|
|
@ -157,8 +155,6 @@ func SetSign(data map[string]interface{}, privateKey string) string { |
|
|
|
|
|
|
|
sign := base64.StdEncoding.EncodeToString(signature) |
|
|
|
|
|
|
|
log.Println("加密后sign值: ", sign) |
|
|
|
log.Println("招行加签end") |
|
|
|
return sign |
|
|
|
} |
|
|
|
|
|
|
@ -182,15 +178,11 @@ func HeaderInfo(appid, secret, sign string) map[string]string { |
|
|
|
delete(headerData, "sign") |
|
|
|
delete(headerData, "secret") |
|
|
|
|
|
|
|
log.Println("header信息", headerData) |
|
|
|
|
|
|
|
return headerData |
|
|
|
} |
|
|
|
|
|
|
|
// 接口验签--各客户端请求我们接口验签
|
|
|
|
func CheckSign(appid, app_secret, timeStamp, nonce, sign string, body map[string]interface{}) error { |
|
|
|
log.Println("请求验签start") |
|
|
|
|
|
|
|
/*time_now := time.Now().Unix() |
|
|
|
|
|
|
|
if time_now-ToInt64(timeStamp) > 10 { |
|
|
@ -209,16 +201,12 @@ func CheckSign(appid, app_secret, timeStamp, nonce, sign string, body map[string |
|
|
|
} |
|
|
|
|
|
|
|
str := CmbHttpBuildQuery(sign_info, false) + "&" + app_secret |
|
|
|
log.Println("加密前数据: ", str) |
|
|
|
sign_str := crypter.Md5Str(str) |
|
|
|
log.Println("加密后数据: ", sign_str) |
|
|
|
|
|
|
|
if sign_str != sign { |
|
|
|
return errors.New("签名不正确") |
|
|
|
} |
|
|
|
|
|
|
|
log.Println("请求验签end") |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
@ -231,8 +219,6 @@ func PostJsonData(url string, param interface{}, headerinfo map[string]string) ( |
|
|
|
return []byte(""), err |
|
|
|
} |
|
|
|
|
|
|
|
log.Println(bytes.NewBuffer(params)) |
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(params)) |
|
|
|
if err != nil { |
|
|
|
return []byte(""), err |
|
|
@ -340,7 +326,6 @@ func HttpBuildjson(data map[string]interface{}, filter_sign bool) string { |
|
|
|
} |
|
|
|
} |
|
|
|
ss, _ := json.Marshal(res) |
|
|
|
log.Println("拼接后的数据: ", string(ss)) |
|
|
|
return string(ss) |
|
|
|
} |
|
|
|
|
|
|
|