1
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -18,13 +17,12 @@ func Sign(appKey, appSecret, method string, timestamp int64, paramJson string) s
|
||||
// 按给定规则拼接参数
|
||||
paramPattern := "app_key" + appKey + "method" + method + "param_json" + paramJson + "timestamp" + strconv.FormatInt(timestamp, 10) + "v2"
|
||||
signPattern := appSecret + paramPattern + appSecret
|
||||
fmt.Println("sign_pattern:" + signPattern)
|
||||
return Hmac(signPattern, appSecret)
|
||||
}
|
||||
|
||||
func SpiSign(appKey, appSecret, timestamp string, paramJson interface{}, signMethod string) string {
|
||||
sortedParamStr := Marshal(paramJson)
|
||||
paramPattern := "app_key" + appKey + "param_json" + sortedParamStr +"timestamp" + timestamp
|
||||
paramPattern := "app_key" + appKey + "param_json" + sortedParamStr + "timestamp" + timestamp
|
||||
signPattern := appSecret + paramPattern + appSecret
|
||||
if signMethod == "hmac-sha256" {
|
||||
return Hmac(signPattern, appSecret)
|
||||
@@ -67,5 +65,3 @@ func Marshal(o interface{}) string {
|
||||
marshal := strings.TrimSpace(buffer.String()) // Trim掉末尾的换行符
|
||||
return marshal
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user