Skip to content

Commit eac7aaa

Browse files
Merge pull request #12 from nhr/BZ844609
Fixed random password generator
2 parents 716af46 + 9158fd3 commit eac7aaa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

wsgi/openshift/openshiftlibs.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ def make_secure_key(key_info):
6363
key = key_info['variable']
6464
original = key_info['original']
6565

66-
chars = '0123456789'
67-
chars += 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
68-
chars += '!@#%^&*()'
69-
chars += '-_ []{}<>~`+=,.;:/?|'
66+
# These are the legal password characters
67+
# as per the Django source code
68+
# (django/contrib/auth/models.py)
69+
chars = 'abcdefghjkmnpqrstuvwxyz'
70+
chars += 'ABCDEFGHJKLMNPQRSTUVWXYZ'
71+
chars += '23456789'
7072

7173
# Use the hash to seed the RNG
7274
random.seed(int("0x" + hashcode[:8], 0))
7375

74-
# Create a random string the same length as the default
76+
# Create a random string the same length as the default
7577
rand_key = ''
7678
for _ in range(len(original)):
7779
rand_pos = random.randint(0,len(chars))

0 commit comments

Comments
 (0)