pass_gen no longer recurses when the user gives invalid input

Former-commit-id: c9756093cd861911b7f5dc05a71fc5a8b858c17e [formerly b10c111640]
Former-commit-id: c8b7974ec39c4e114578314814c5c2a982339736
This commit is contained in:
2022-11-25 19:23:14 -05:00
parent d301cf6298
commit bca2af0ed8
+11 -6
View File
@@ -117,12 +117,17 @@ def string_gen(_complexity, _length): # generates and returns a random string b
def pass_gen(): # prompts the user for necessary information to generate a password and passes it to string_gen
try:
_length = int(input('password length: '))
except ValueError:
print(f"\n\u001b[38;5;9merror: a non-integer value was input for password length\u001b[0m\n")
_gen = pass_gen()
return _gen
_length = 9
while True:
try:
_length = int(input('password length: '))
except ValueError:
continue
else:
if _length < 1:
continue
else:
break
_complexity = str(input('password complexity - simple (for compatibility) or complex (for security)? (s/C) '))
if _complexity != 's' and _complexity != 'S':
_complexity = 'c'