-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (28 loc) · 1.02 KB
/
main.py
File metadata and controls
37 lines (28 loc) · 1.02 KB
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
36
37
import secrets
import string
import random
lower = string.ascii_lowercase
upper = string.ascii_uppercase
digits = string.digits
special = string.punctuation
allChars = lower + upper + digits + special
password = ""
pwLen = int(input("How long should the password be? "))
minUpper = int(input("Minimum Upper Case: "))
minLower = int(input("Minimum Lower Case: "))
minDigits = int(input("Minimum Numbers: "))
minSpec = int(input("Minimum Special: "))
for i in range(minUpper):
password += "".join(random.choice(secrets.choice(upper)))
for i in range(minLower):
password += "".join(random.choice(secrets.choice(lower)))
for i in range(minDigits):
password += "".join(random.choice(secrets.choice(digits)))
for i in range(minSpec):
password += "".join(random.choice(secrets.choice(special)))
remaining = pwLen - minLower - minUpper - minDigits - minSpec
for i in range(remaining):
password += "".join(random.choice(secrets.choice(allChars)))
password = list(password)
random.shuffle(password)
print("".join(password))