Я хотел создать программу, которая сообщит вам случайный пароль и проверяет действительность пароля. Я создал случайное значение из 33-126 (это значение ascii, которое дает вывод с клавиатуры), а затем добавить его в пароль и проверьте действительность. но время ожидания истекло, и никаких выходных данных не было. когда я отлаживаю его, я увидел, что он случайным образом останавливается в случайной точке. пароль был в форме списка, чтобы облегчить мою работу. Я проверил действительность пароля, список (пароль) был например - password = ['2', 'f', 'W', '@', '/']
Вы можете видеть, что пароль [0] равен '2', а не 2, поэтому я создал для проверки int type
, поэтому он был застрял там
def makePassword():
password = []
for _ in range(1, random.randint(5, 21)):
rm = random.randint(33, 126)
ascii_value = chr(rm)
password.append(ascii_value)
return password
def isalnum(password):
password = list(password)
index = random.randint(0, len(password))
skw = chr(random.choice([random.randint(48, 57), random.randint(65, 90), random.randint(97, 122)]))
for i in password:
if not i.isalnum():
password.insert(index, skw)
return password
def isalpha(password):
password = list(password)
index = random.randint(0, len(password))
skw = chr(random.choice([random.randint(65, 90), random.randint(97, 122)]))
for i in password:
if not i.isalpha():
password.insert(index, skw)
return password
def isdigit(password):
password = list(password)
index = random.randint(0, len(password))
skw = chr(random.randint(48, 57))
for i in password:
if not i.isdigit():
password.insert(index, skw)
return password
def isupper(password):
password = list(password)
index = random.randint(0, len(password))
skw = chr(random.randint(65, 90))
for i in password:
if not i.isupper():
password.insert(index, skw)
return password
def islower(password):
password = list(password)
index = random.randint(0, len(password))
skw = chr(random.randint(97, 122))
for i in password:
if not i.isalnum():
password.insert(index, skw)
return password
word = makePassword()
for i in word:
if not i.isalnum():
word = isalnum(word)
if not i.isalpha():
word = isalpha(word)
if not i.isdigit():
word = isdigit(word)
if not i.isupper():
word = isupper(word)
if not i.lower():
word = islower(word)
print(word)```