Skip to content

Instantly share code, notes, and snippets.

@doctaphred
Last active March 7, 2018 18:25
Show Gist options
  • Save doctaphred/d8f076fff93b8760968a306278e0a22c to your computer and use it in GitHub Desktop.
Save doctaphred/d8f076fff93b8760968a306278e0a22c to your computer and use it in GitHub Desktop.
Generate a secret key suitable for use with Django
#!/usr/bin/env python
"""Generate a new secret key suitable for use with Django.
Uses the same process as django.core.management.utils:get_random_secret_key.
"""
from random import SystemRandom
random = SystemRandom()
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
print(''.join(random.choice(chars) for _ in range(50)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment