So I'm trying to create a password generator that continually generates completely random yet unique sequence of characters that have not been generated before. (the code stops once all possible combinations under the character limit variable have been generated.)
I have this but I understand that it generates duplicates and never ends.
import secrets
import string
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
alphabet = letters + digits + special_chars
while True:
char_limit = secrets.choice(range(3, 5))
pwd = ''
for i in range(char_limit):
pwd += ''.join(secrets.choice(alphabet))
print(pwd)
Is there a library for this? A built-in feature? Am I going about it completely the wrong way? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire