Python Secrets Module
Cryptographic secure random — token_bytes, token_hex, compare_digest. This category documents 7 Python secrets module entries, and each page gives you the full syntax, the parameter list, the return value, and a runnable example. The entries include: secrets.token_bytes(), secrets.token_hex(), secrets.token_urlsafe(), secrets.compare_digest(), secrets.choice(), secrets.randbelow(), secrets.SystemRandom(). secrets.token_bytes() returns cryptographically secure random bytes (for tokens, keys, etc.). secrets.token_hex() returns a random hex string (for secure tokens). secrets.token_urlsafe() returns a URL-safe random string (base64 encoded, no padding). secrets.compare_digest() compares two strings in constant time (mitigates timing attacks). secrets.choice() returns a cryptographically secure random element from a sequence. You can also search across every category from the search page, browse the complete A–Z index, or try any example in the Python playground. Python Reference documents 978+ functions, methods, and modules across 114 categories of the standard library, and every entry in this Secrets Module category follows the same format — syntax first, then what it does, the parameters it accepts, what it returns, and a working code example — so once you have read one page you can read them all.