Skip to main content

hmac

HMAC keyed-hash message authentication. Builds on hashlib.

Source-of-record: Lib/hmac.py, hmac docs.

API

Function / classPurpose
new(key, msg=None, digestmod)Construct HMAC.
digest(key, msg, digest)One-shot.
compare_digest(a, b)Constant-time compare.
HMAC.update(msg)Feed bytes.
HMAC.digest() / hexdigest()Finalise.
HMAC.copy()Fork.
HMAC.name, digest_size, block_sizeMetadata.

digestmod accepts a hashlib name, constructor, or hashlib.new-returned object.

Gopy status

AreaState
HMAC, new, digestComplete.
compare_digestComplete via subtle.ConstantTimeCompare.

Reference

  • CPython 3.14: hmac.
  • Lib/hmac.py.
  • module/_hmac/. gopy port.
  • RFC 2104.