Revised patch for more password entropy

This commit is contained in:
Alan Fairless
2013-11-01 09:51:35 -05:00
parent dc4d589ce0
commit 0824f004d9
4 changed files with 16 additions and 6 deletions

View File

@@ -1006,4 +1006,13 @@ def combine_vars(a, b):
else:
return dict(a.items() + b.items())
def random_password(length=20, chars=C.DEFAULT_PASSWORD_CHARS):
'''Return a random password string of length containing only chars.'''
password = []
while len(password) < length:
new_char = os.urandom(1)
if new_char in chars:
password.append(new_char)
return ''.join(password)