SteelReed

Search

Search posts, questions…

SecurityQuestion 4 / 24

Middle

How does HMAC differ from a plain hash and a digital signature, and why sign requests despite HTTPS?

Short answer

A plain hash can be computed by anyone, so it proves no origin; HMAC needs a shared secret; a digital signature signs with a private key and verifies with the public key. HTTPS only protects the transport; signing protects the message itself.

who can verifywho can verifyMessageHash: anyone computesHMAC: shared secretSignature: private keyOnly secret holdersAnyone with public key

3 points to say:

  1. Don't roll your own sha256(secret + message); use standard HMAC and a constant-time comparison.
  2. Digital signatures give non-repudiation and suit many consumers (RS256/ES256 + JWKS); HMAC is very fast and fits 1–1 webhooks.
  3. TLS terminates at the proxy and does not stop replay; sign the raw body bytes, with a timestamp inside the signed part.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.