Skip to content

Instantly share code, notes, and snippets.

@ape364
ape364 / secret.py
Created May 15, 2017 19:43
Generate secret key
"""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/
Code taken from source: https://hg.python.org/cpython/file/3.6/Lib/secrets.py
"""
__all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom',
'token_bytes', 'token_hex', 'token_urlsafe',
'compare_digest',