This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user