Skip to content

Commit

Permalink
Fixes netbox-community#1092: Increase randomness in SECRET_KEY genera…
Browse files Browse the repository at this point in the history
…tion tool
  • Loading branch information
jeremystretch committed Apr 21, 2017
1 parent aaf3004 commit a74233a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions netbox/generate_secret_key.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python
# This script will generate a random 50-character string suitable for use as a SECRET_KEY.
import os
import random

charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(-_=+)'
random.seed = (os.urandom(2048))
print(''.join(random.choice(charset) for c in range(50)))
secure_random = random.SystemRandom()
print(''.join(secure_random.sample(charset, 50)))

0 comments on commit a74233a

Please sign in to comment.