Files
rudder-go-sdk/webhook.go
T
2026-08-28 13:36:03 +03:00

19 lines
346 B
Go

package rudder
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
func VerifyWebhookSignature(secret string, body []byte, signature string) bool {
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(body)
expected, err := hex.DecodeString(signature)
if err != nil {
return false
}
return hmac.Equal(mac.Sum(nil), expected)
}