Webhook Signature Verification Builder
Implements secure HMAC-SHA256 webhook signature verification to prevent spoofing.
Works with:
chatgpt
claude
gemini
Prompt
Act as a senior backend security engineer. Write a secure webhook signature verification function in [PROGRAMMING_LANGUAGE] utilizing HMAC-SHA256 to authenticate incoming payloads from [SERVICE_NAME]. Include timing-attack protection.
Example Output
python
import hmac
import hashlib
def verify_signature(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), payload, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
import hmac
import hashlib
def verify_signature(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), payload, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)