Used python's secrets class to generate more secure passwords

This commit is contained in:
agileDesigner 2022-01-20 23:13:28 +00:00
parent 3d3020d445
commit 3edca5c39b
No known key found for this signature in database
GPG key ID: 2278E3A799484F16

View file

@ -1,4 +1,4 @@
import random
import secrets
class PasswordGenerator():
"""
@ -68,14 +68,11 @@ class PasswordGenerator():
possible characters that should be considered and generates the
password.
"""
password = ''
self.use_upper()
self.use_nums()
self.use_symbols()
while len(password) < self._length:
password += random.choice(self._available_chars)
print('\nYour new password is: ', password)
print('\n')
password = ''.join(secrets.choice(self._available_chars) for i in range(self._length))
print('\nYour new password is: ', password+'\n')
def main():
"""