HTTP Digest Authentication
Digest auth is an HTTP challenge-response scheme that proves knowledge of a
password without sending it in cleartext, by hashing it together with a
server nonce. This reference lists every parameter in the WWW-Authenticate
challenge and the Authorization response, plus the exact hashing algorithm —
and a live computer that reproduces the response value.
How it works
The server replies 401 with a challenge; the client answers with a hashed
response. With qop=auth the algorithm (RFC 7616) is:
HA1 = H(username ":" realm ":" password)
HA2 = H(method ":" digestURI)
response = H(HA1 ":" nonce ":" nc ":" cnonce ":" qop ":" HA2)
H is the function named by algorithm — MD5 by default or SHA-256. The
legacy form (no qop) is response = H(HA1 ":" nonce ":" HA2). With
qop=auth-int, HA2 = H(method ":" digestURI ":" H(entityBody)) so the body is
covered too. The client returns username, realm, nonce, uri, qop,
nc, cnonce, response and echoes opaque.
Tips and notes
ncis an 8-digit hex counter that must increase for each request reusing the samenonce; the server rejects repeats to block replay.- A
stale=trueflag means the nonce expired but the credentials were fine — the client retries with a fresh nonce, no password prompt needed. - MD5 Digest is cryptographically weak; use
SHA-256where supported and always run Digest over TLS. - The browser-side computer below uses Web Crypto for SHA-256; MD5 is computed with a small built-in implementation since Web Crypto does not provide it.