PyDocs

Nav

Cryptographic Services

compare_digest

hmac

function · Added in 3.3
  • compare_digest(a, b)
Return 'a == b'.

This function uses an approach designed to prevent
timing analysis, making it appropriate for cryptography.

a and b must both be of the same type: either str (ASCII only),
or any bytes-like object.

Note: If a and b are of different lengths, or if an error occurs,
a timing attack could theoretically reveal information about the
types and lengths of a and b--but not their values.
Changed in 3.10
  • 3.10: The function uses OpenSSL’s CRYPTO_memcmp() internally when available.
0 Examples
No examples for hmac/compare_digest.
See Also
No see-alsos for hmac/compare_digest
0 Notes
No notes for compare_digest