π GitHub Webhook Verification
// Header: X-Hub-Signature-256: sha256=<hex>
// Algorithm: HMAC-SHA256, key = your webhook secret
// Message: raw request body (bytes, not parsed JSON)
const sig = 'sha256=' + hmacSHA256(body, secret)
if (!timingSafeEqual(sig, req.headers['x-hub-signature-256'])) throw new Error('Invalid')
π³ Stripe Webhook Verification
// Header: Stripe-Signature: t=<ts>,v1=<hex>
// Signed payload: timestamp + '.' + rawBody
// Algorithm: HMAC-SHA256, key = endpoint signing secret
const payload = timestamp + '.' + rawBody
const expected = hmacSHA256(payload, stripeSecret)
π API Request Signing
// Common pattern: sign method + path + timestamp + body hash
const canonicalReq = method + '\n' + path + '\n' + timestamp + '\n' + sha256(body)
const signature = hmacSHA256(canonicalReq, apiSecret)
// Send in header: Authorization: HMAC-SHA256 sig=<hex>,ts=<timestamp>