We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7e91671 commit 8bc0bd4Copy full SHA for 8bc0bd4
files/generate_django_secret_key.py
@@ -1,16 +1,6 @@
1
#!/usr/bin/env python
2
-"""Pseudo-random django secret key generator"""
3
-from __future__ import print_function
+# This script will generate a random 50-character string suitable for use as a SECRET_KEY.
+import secrets
4
5
-import random
6
-
7
-chars = (
8
- "abcdefghijklmnopqrstuvwxyz"
9
- "ABCDEFGHIJKLMNOPQRSTUVXYZ"
10
- "0123456789"
11
- "#()^[]-_*%&=+/"
12
-)
13
14
-SECRET_KEY = "".join([random.SystemRandom().choice(chars) for i in range(50)])
15
16
-print(SECRET_KEY)
+charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(-_=+)'
+print(''.join(secrets.choice(charset) for _ in range(50)))
0 commit comments