Skip to content

Instantly share code, notes, and snippets.

@KatUser
Created July 18, 2020 00:42
Show Gist options
  • Save KatUser/09b0daab64f9c9050dc51870987a2558 to your computer and use it in GitHub Desktop.
Save KatUser/09b0daab64f9c9050dc51870987a2558 to your computer and use it in GitHub Desktop.
pswd generator
import random
digits = '23456789'
lowercase_letters = 'abcdefghjkmnpqrstuvwxyz'
uppercase_letters = 'ABCDEFGHJKMNPQRSTUVWXYZ'
punctuation = '!#$%&*+-=?@^_.'
chars = ''
exceptions = 'Iil1Lo0O'
t = ''
while True:
numpsw = input('Сколько нужно сгенерировать паролей?:')
numpsw = numpsw.strip()
if numpsw.isdigit() and int(numpsw) > 0:
break
else:
continue
while True:
lengthpsw = input('Длина пароля?:')
lengthpsw = lengthpsw.strip()
if lengthpsw.isdigit() and int(lengthpsw) > 0:
break
else:
continue
while True:
digitsinpsw = input('Включать ли цифры 0123456789? Да или Нет?:')
digitsinpsw = digitsinpsw.strip()
if digitsinpsw.lower() == 'да':
chars = chars + digits
break
if digitsinpsw.lower() == 'нет':
break
else:
continue
while True:
upperletterspsw = input('Включать ли прописные буквы ABCDEFGHIJKLMNOPQRSTUVWXYZ? Да или Нет?:')
upperletterspsw = upperletterspsw.strip()
if upperletterspsw.lower() == 'да':
chars = chars + uppercase_letters
break
if upperletterspsw.lower() == 'нет':
break
else:
continue
while True:
lowerletterspsw = input('Включать ли строчные буквы abcdefghijklmnopqrstuvwxyz? Да или Нет?:')
lowerletterspsw = lowerletterspsw.strip()
if lowerletterspsw.lower() == 'да':
chars = chars + lowercase_letters
break
if lowerletterspsw.lower() == 'нет':
break
else:
continue
while True:
punctpsw = input('Включать ли символы !#$%&*+-=?@^_? Да или Нет?:')
punctpsw = punctpsw.strip()
if punctpsw.lower() == 'да':
chars = chars + punctuation
break
if punctpsw.lower() == 'нет':
break
else:
continue
while True:
exceptionpsw = input('Исключать ли неоднозначные символы Iil1Lo0O?:')
exceptionpsw = exceptionpsw.strip()
if exceptionpsw.lower() == 'да':
break
if exceptionpsw.lower() == 'нет':
chars = chars + exceptionpsw
else:
continue
def generate_password(chars, lengthpsw):
for j in range(int(numpsw)):
pswd = ''
while len(pswd) < int(lengthpsw):
for i in range(int(lengthpsw)):
t = random.choice(list(chars))
pswd = pswd + t
print(f'Ваш Пароль : {pswd}')
generate_password(chars, lengthpsw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment