pydoc > secrets

🏷️ NAME

secrets

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ”‘ Generate secure random bytessecrets.token_bytes(16)Return 16 random bytes
πŸ”— Generate URL‑safe tokensecrets.token_urlsafe(16)Return random Base64 URL‑safe string
πŸ”’ Generate hexadecimal tokensecrets.token_hex(16)Return random hex string
🎲 Pick a random elementsecrets.choice(seq)Choose a random element from a sequence
πŸ”’ Secure random integersecrets.randbelow(n)Return a random int in [0, n)
⏱️ Timing‑safe comparisonsecrets.compare_digest(a, b)Compare two strings without leaking timing info

πŸ“š MODULE REFERENCE

https://docs.python.org/3.10/library/secrets.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

πŸ“– DESCRIPTION

Generate cryptographically strong pseudo-random numbers suitable for managing secrets such as account authentication, tokens, and similar.

See PEP 506 for more information. https://www.python.org/dev/peps/pep-0506/

🧬 CLASSES

random.Random(_random.Random)
random.SystemRandom

πŸ” class SystemRandom(Random)

Alternate random number generator using sources provided by the operating system (such as /dev/urandom on Unix or CryptGenRandom on Windows).

Not available on all systems (see os.urandom() for details).

Method resolution order: SystemRandom, Random, _random.Random, builtins.object

Methods defined here

Methods inherited from Random

Class methods inherited from Random

Data descriptors inherited from Random

Data and other attributes inherited from Random

Static methods inherited from _random.Random

πŸ› οΈ FUNCTIONS

πŸ“¦ DATA

__all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom', 'token_b...']

πŸ“ FILE

/usr/lib/python3.10/secrets.py

secrets
🏷️ NAME πŸš€ Quick Reference πŸ“š MODULE REFERENCE πŸ“– DESCRIPTION 🧬 CLASSES
πŸ” class SystemRandom(Random)
πŸ› οΈ FUNCTIONS πŸ“¦ DATA πŸ“ FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 16:14 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^