Skip to content

Instantly share code, notes, and snippets.

@a-aganesov
Last active January 26, 2019 19:22
Show Gist options
  • Save a-aganesov/17ecbea52b9458b6d6f328ca897f31e9 to your computer and use it in GitHub Desktop.
Save a-aganesov/17ecbea52b9458b6d6f328ca897f31e9 to your computer and use it in GitHub Desktop.
Generator and Checker Password
def password_2in1():
import random
# Блок генерации пароля // Block generation password
list_symbols_numbers = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm',
'Q', "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M",
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+'
]
list_words = []
password = []
max_length = int(input('Введите максимальную длину пароля // Enter maximum password length'))
# Заполнение нового списка рандомными символами // adding in new list random symbols
for x in range(max_length):
random_symbol = random.randint(0, len(list_symbols_numbers) - 1)
password.append(list_symbols_numbers[random_symbol])
# склейка нового списка в переменную
ready_pass = ''.join(password)
# Конец блока генерации пароля // End block
print(ready_pass)
# Блок проверки на надёжность // check on strength
answer = input('Желаете проверить надёжность сгенерированного пароль? (Ответьте "+" или "-") ')
if answer == '+':
if len(ready_pass) < 6:
return "Недопустимый пароль// Invalid Password"
elif ready_pass.isdigit is True or ready_pass.isupper() or ready_pass.islower():
return "Ненадёжный пароль // Unreliable Password"
# Проверка по регистру и наличию цифр или букв // Сheck for letters and numbers, and check for case
elif ready_pass.isalpha() \
or ready_pass.isalpha() and ready_pass.islower() \
or ready_pass.isalpha() and ready_pass.isupper() \
or ready_pass.isalnum() and ready_pass.islower() \
or ready_pass.isalnum() and ready_pass.isupper():
return "Слабый пароль // Weak Password"
else:
return "Надёжный пароль // Strength Password"
else:
quit()
# Конец блока проверки End block check
# Вывод OUTPUT
global_pass = password_2in1()
print(global_pass)
@a-aganesov
Copy link
Author

It's my first big program(big program for me:) ), what you can say about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment