mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
a38a38218b
--------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
15 lines
348 B
Python
15 lines
348 B
Python
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()
|