Update main.go
Browse files
main.go
CHANGED
|
@@ -1722,9 +1722,10 @@ func generateSignature(messageText string, requestID string, timestampMs int64,
|
|
| 1722 |
derivedHex := fmt.Sprintf("%x", h.Sum(nil))
|
| 1723 |
|
| 1724 |
// Layer2: 生成签名
|
|
|
|
| 1725 |
canonicalString := fmt.Sprintf(
|
| 1726 |
"requestId,%s,timestamp,%d,user_id,%s|%s|%d",
|
| 1727 |
-
requestID, timestampMs, userID,
|
| 1728 |
)
|
| 1729 |
h2 := hmac.New(sha256.New, []byte(derivedHex))
|
| 1730 |
h2.Write([]byte(canonicalString))
|
|
|
|
| 1722 |
derivedHex := fmt.Sprintf("%x", h.Sum(nil))
|
| 1723 |
|
| 1724 |
// Layer2: 生成签名
|
| 1725 |
+
encodedMessage := base64.StdEncoding.EncodeToString([]byte(messageText))
|
| 1726 |
canonicalString := fmt.Sprintf(
|
| 1727 |
"requestId,%s,timestamp,%d,user_id,%s|%s|%d",
|
| 1728 |
+
requestID, timestampMs, userID, encodedMessage, timestampMs,
|
| 1729 |
)
|
| 1730 |
h2 := hmac.New(sha256.New, []byte(derivedHex))
|
| 1731 |
h2.Write([]byte(canonicalString))
|