Skip to content

Commit b85ff53

Browse files
committed
first commit
0 parents  commit b85ff53

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pypassgen.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import random, string
2+
3+
def generate_password(length, caps=True, numbers=True, symbols=True):
4+
"""
5+
Secure random password generator
6+
"""
7+
num_of_nmbrs = random.randint((length)//10, (length)//4) if numbers else 0
8+
num_of_symbs = random.randint((length)//10, (length)//4) if symbols else 0
9+
num_of_chars = length - num_of_nmbrs - num_of_symbs
10+
11+
passwd = []
12+
chars = string.ascii_lowercase
13+
if caps:
14+
chars += string.ascii_uppercase
15+
for i in range(num_of_chars):
16+
passwd.append(random.choice(chars))
17+
if numbers:
18+
for i in range(num_of_nmbrs):
19+
passwd.append(random.choice(string.digits))
20+
if symbols:
21+
for i in range(num_of_symbs):
22+
passwd.append(random.choice(string.punctuation))
23+
24+
random.shuffle(passwd)
25+
return ''.join(passwd)

0 commit comments

Comments
 (0)