Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, string
- from random import randint
- def weakPassword(r):
- '''Pick random word from passwords list'''
- passwordsList = ['123456', '123456789', 'qwerty', '12345678', '111111', '1234567890', '1234567', 'password', '123123', '987654321', 'qwertyuiop', 'mynoob', '123321', '666666', '18atcskd2w', '7777777', '1q2w3e4r', '654321', '555555', '3rjs1la7qe', 'google', '1q2w3e4r5t', '123qwe', 'zxcvbnm', '1q2w3e']
- r = random.choice(passwordsList)
- print(r)
- def strongPassword(r):
- '''Generate random password'''
- password = []
- a = random.sample(string.ascii_letters, k = randint(3, 8)) #random letters
- a = ''.join(a)
- password.append(a)
- b = random.sample(string.digits, k = randint(3, 8)) #random digits
- b = ''.join(b)
- password.append(b)
- c = random.sample(string.punctuation, k = randint(3, 8)) #random symbols
- c = ''.join(c)
- password.append(c)
- random.shuffle(password) #shuffle digits, symbols and letters order
- password = ''.join(password)
- print(password)
- def strongOrWeak():
- '''Choose how strong password will be'''
- choice = input('Do you want strong or weak password? w/s: ')
- while True:
- if choice == 'w':
- p = print('Generated password is: ')
- weakPassword(p)
- newPassword()
- if choice == 's':
- p = print('Generated password is: ')
- strongPassword(p)
- newPassword()
- else:
- choice = input("This is not correct answer! Please type 'w' or 's': ")
- def newPassword():
- '''Generate new password'''
- choice = input('Do you want to generate new password? y/n: ')
- while True:
- if choice == 'y':
- strongOrWeak()
- if choice == 'n':
- quit()
- else:
- choice = input("This is not correct answer! Please type 'y' or 'n': ")
- strongOrWeak()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement