secrets — Generate secure random numbers for managing secrets — Python 3.16.0a0 documentation

docs.python.org

Tin mới

hmac — Keyed-Hashing for Message Authentication

Generic Operating System Services

Python Module Index

3.16.0a0 Documentation

The Python Standard Library

Cryptographic Services

random: Generate pseudo-random numbers with various common distributions.

The secrets module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.

How many bytes should tokens use?¶

To be secure against brute-force attacks, tokens need to have sufficient randomness. Unfortunately, what is considered sufficient will necessarily increase as computers get more powerful and able to make more guesses in

bytes-like objects

Return True if strings or bytes-like objects a and b are equal, otherwise False, using a “constant-time compare” to reduce the risk of timing attacks. See hmac.compare_digest() for additional details.