Improved minimum quality of generated passwords

This commit is contained in:
2022-04-19 16:43:30 -04:00
parent 24acd1cb87
commit 5fc74ac2b3
+6
View File
@@ -81,6 +81,12 @@ def pass_gen():
else:
_complexity = string.ascii_letters + string.digits + string.punctuation
_gen = ''.join(random.SystemRandom().choice(_complexity) for _ in range(_length))
_min_special, _special = round(.2 * _length), 0
for _character in _gen:
if not _character.isalpha():
_special += 1
if _special < _min_special:
_gen = pass_gen()
return _gen