-
Notifications
You must be signed in to change notification settings - Fork 0
/
ch07_pw_detection.py
40 lines (29 loc) · 1008 Bytes
/
ch07_pw_detection.py
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
### Chapter 7 Project: Strong Password Detection
#>= 8 characters, Upper and lower, and has >= 1 digit
import re
char = re.compile(r'\S{8,}')
lower_case = re.compile(r'[a-z]')
upper_case = re.compile(r'[A-Z]')
digit = re.compile(r'\d')
Pass = False
while Pass == False:
x = 0
print('Create your Password: \nMust contain at least 8 characters, a lower case, an upper case, and a digit')
pwInput = input()
if char.search(pwInput) == None:
print('* Must be at least 8 characters')
x += 1
if lower_case.search(pwInput) == None:
print('* Must contain one lower case')
x += 1
if upper_case.search(pwInput) == None:
print('* Must contain an upper case')
x += 1
if digit.search(pwInput) == None:
print('* Must contain a digit')
x += 1
if x == 0:
print('Password Saved...')
break
else:
print('\n---Please Try Again---\n')