Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Have the program create random strong passwords mixing upper and lower case,
- symbols and numbers.
- The user can choose how long they want the password to be.
- A strong password must contain:
- • a capital letter
- • a number
- • a symbol.
- """
- import random
- caps =[] # A = 65 Z = 90
- numb = [] #48-57
- symb = [] # 33-47, 58-64, 123-126
- lows = [] #97 122
- alls = []
- for i in range(65,91):
- caps.append(chr(i))
- for i in range(97,123):
- lows.append(chr(i))
- for i in range(48,58):
- numb.append(chr(i))
- for i in range(33,48):
- symb.append(chr(i))
- for i in range(58,65):
- symb.append(chr(i))
- for i in range(123,127):
- symb.append(chr(i))
- # populates the alls list
- alls.extend(caps)
- alls.extend(numb)
- alls.extend(symb)
- alls.extend(lows)
- #print(alls)
- chars_needed = int()
- password=[] # to hold the password
- while chars_needed <3:
- chars_needed = int(input("Enter number of characters you'd like (min 3) >> "))
- password.append(random.choice(caps))
- password.append(random.choice(numb))
- password.append(random.choice(symb))
- #print(password)
- for i in range(chars_needed-3):
- password.append(random.choice(alls))
- random.shuffle(password)
- passwordstring = ""
- for i in range(len(password)):
- passwordstring += password[i]
- #passwordstring = passwordstring + password[i]
- print(password)
- print(passwordstring)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement