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