Commit b516b4ae authored by Michal Čihař's avatar Michal Čihař

Get rid of tabs and spaces mix

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 8c9f5bec
...@@ -72,27 +72,27 @@ def openshift_secure(default_keys, secure_function = 'make_secure_key'): ...@@ -72,27 +72,27 @@ def openshift_secure(default_keys, secure_function = 'make_secure_key'):
# This function transforms default keys into per-deployment random keys; # This function transforms default keys into per-deployment random keys;
def make_secure_key(key_info): def make_secure_key(key_info):
hashcode = key_info['hash'] hashcode = key_info['hash']
original = key_info['original'] original = key_info['original']
# These are the legal password characters # These are the legal password characters
# as per the Django source code # as per the Django source code
# (django/contrib/auth/models.py) # (django/contrib/auth/models.py)
chars = 'abcdefghjkmnpqrstuvwxyz' chars = 'abcdefghjkmnpqrstuvwxyz'
chars += 'ABCDEFGHJKLMNPQRSTUVWXYZ' chars += 'ABCDEFGHJKLMNPQRSTUVWXYZ'
chars += '23456789' chars += '23456789'
# Use the hash to seed the RNG # Use the hash to seed the RNG
random.seed(int("0x" + hashcode[:8], 0)) random.seed(int("0x" + hashcode[:8], 0))
# Create a random string the same length as the default # Create a random string the same length as the default
rand_key = '' rand_key = ''
for _ in range(len(original)): for _ in range(len(original)):
rand_pos = random.randint(0,len(chars)) rand_pos = random.randint(0,len(chars))
rand_key += chars[rand_pos:(rand_pos+1)] rand_key += chars[rand_pos:(rand_pos+1)]
# Reset the RNG # Reset the RNG
random.seed() random.seed()
# Set the value # Set the value
return rand_key return rand_key
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment