Skip to content

Commit 3f8724c

Browse files
First commit
1 parent fd76750 commit 3f8724c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Password-Generator/main.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import secrets
2+
import string
3+
4+
letters = string.ascii_letters
5+
digits = string.digits
6+
special_chars = string.punctuation
7+
8+
alphabet = letters + digits + special_chars
9+
10+
pwd_length = 12
11+
12+
pwd = ''
13+
for i in range(pwd_length):
14+
pwd += ''.join(secrets.choice(alphabet))
15+
16+
print(pwd)
17+
18+
while True:
19+
pwd = ''
20+
for i in range(pwd_length):
21+
pwd += ''.join(secrets.choice(alphabet))
22+
23+
if (any(char in special_chars for char in pwd) and
24+
sum(char in digits for char in pwd)>=2):
25+
break
26+
print(pwd)

0 commit comments

Comments
 (0)