-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (25 loc) · 773 Bytes
/
Copy pathmain.py
File metadata and controls
35 lines (25 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import random
from helper import ask
LOWERCASE = "abcdefghijklmnopqrstuvwxyz"
UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
NUMBERS = "0123456789"
SYMBOLS = "!@#$%^&*()_+-=[]{}|;:,.<>?"
characters = LOWERCASE
password = ""
while True:
try:
length = int(input("Enter password length: "))
if length > 0:
break
print("Length must be greater than 0.")
except ValueError:
print("Enter a valid number!")
if ask("Include numbers? (y/n): ") == "y":
characters += NUMBERS
if ask("Include uppercase? (y/n): ") == "y":
characters += UPPERCASE
if ask("Include symbols? (y/n): ") == "y":
characters += SYMBOLS
for _ in range(length):
password += random.choice(characters)
print(f'Generated password: {password}')