mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Revised patch for more password entropy
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user