Files

19 lines
346 B
Go
Raw Permalink Normal View History

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)
}