diff --git a/netbox/extras/webhooks.py b/netbox/extras/webhooks.py new file mode 100644 index 000000000..a48a8038b --- /dev/null +++ b/netbox/extras/webhooks.py @@ -0,0 +1,14 @@ +import hashlib +import hmac + + +def generate_signature(request_body, secret): + """ + Return a cryptographic signature that can be used to verify the authenticity of webhook data. + """ + hmac_prep = hmac.new( + key=secret.encode('utf8'), + msg=request_body, + digestmod=hashlib.sha512 + ) + return hmac_prep.hexdigest()