Skip to content

Instantly share code, notes, and snippets.

@nervouna
Forked from geoffalday/secretkey.py
Last active March 31, 2017 13:38
Show Gist options
  • Save nervouna/cd58fb09c22826eaaff996793de72d85 to your computer and use it in GitHub Desktop.
Save nervouna/cd58fb09c22826eaaff996793de72d85 to your computer and use it in GitHub Desktop.
How to generate a secret key with Python
# How to generate a secret key with Python
# via http://flask.pocoo.org/docs/quickstart/
import os
import binascii
os.urandom(24)
# Out: b'\x83[\x14\xa4s\xde\xdd\xed\xed/\xd0&-\xc6N\xd5\xb7\xf8O\xd5(\xce\xca,'
# Or if you want a prettier one:
binascii.hexlify(os.urandom(24))
# Out: b'5a77d33bc5e2fd877540d80a03cd75e74926c8e8ee9e0c2b'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment