-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
35 lines (23 loc) · 852 Bytes
/
Copy pathscript.py
File metadata and controls
35 lines (23 loc) · 852 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
import random
import string
def generator(length=10, have_upper=True, have_lower=True, have_numbers=True, have_symbols=True):
upper_letters = string.ascii_uppercase
lower_letters = string.ascii_lowercase
numbers = string.digits
symbols = "!@#$%^&*"
password = set()
count = 1
while count <= length:
if have_upper and count <= length:
password.add(random.choice(upper_letters))
count += 1
if have_lower and count <= length:
password.add(random.choice(lower_letters))
count += 1
if have_numbers and count <= length:
password.add(random.choice(numbers))
count += 1
if have_symbols and count <= length:
password.add(random.choice(symbols))
count += 1
return "".join(password)