-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab7.15.py
More file actions
45 lines (33 loc) · 841 Bytes
/
Lab7.15.py
File metadata and controls
45 lines (33 loc) · 841 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
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python3
import string
import random
def verify(pswd: str) -> bool:
letters = string.ascii_uppercase + string.ascii_lowercase
digits = string.digits
special = string.punctuation
for ch in letters:
if pswd.count(ch) > 0:
break
else:
return False
for ch in digits:
if pswd.count(ch) > 0:
break
else:
return False
for ch in special:
if pswd.count(ch) > 0:
break
else:
return False
return True
def gen_pswd() -> str:
chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + string.punctuation
size = random.randint(8, 12)
return ''.join(random.choice(chars) for x in range(size))
pswd = ''
while True:
pswd = gen_pswd()
if verify(pswd):
break
print(pswd)