package ingest import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "strconv" "time" ) // Sign 与后台 internal/pkg/hmac.Sign 完全一致: // HMAC_SHA256(secret, timestamp + "." + nonce + "." + body) 的十六进制串。 // bodyRaw 必须是请求体原始字节,确保与后台收到的字节严格一致。 func Sign(secret, timestamp, nonce, body string) string { mac := hmac.New(sha256.New, []byte(secret)) mac.Write([]byte(timestamp)) mac.Write([]byte(".")) mac.Write([]byte(nonce)) mac.Write([]byte(".")) mac.Write([]byte(body)) return hex.EncodeToString(mac.Sum(nil)) } // NowTS 返回当前 Unix 秒字符串(X-Timestamp 用)。 func NowTS() string { return strconv.FormatInt(time.Now().Unix(), 10) }