-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassStrengthCheck.py
More file actions
51 lines (46 loc) · 1.58 KB
/
Copy pathpassStrengthCheck.py
File metadata and controls
51 lines (46 loc) · 1.58 KB
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
46
47
48
49
50
51
#! Python3
# Prompts user for password and tests it for strength before exiting
import re
from getpass import getpass
def passCheck():
upperCheck = re.compile(r'[A-Z]')
lowerCheck = re.compile(r'[a-z]')
digitCheck = re.compile(r'[0-9]')
charCheck = re.compile(r'[\!\@\#\$\%\^\&\*\_\-\+\=\?]')
while True:
password = getpass(prompt='\nPlease enter a password: ')
if len(password) < 8:
print('Please include at least than 8 characters')
if lowerCheck.search(password) is None:
print('Please include at least one lowercase letter [a-z]')
if upperCheck.search(password) is None:
print('Please include at least one uppercase letter [A-Z]')
if digitCheck.search(password) is None:
print('Please include at least one digit [0-9] ')
if charCheck.search(password) is None:
print('Please include at least one special character '
'[!@#$%^&*_-+=?]')
if len(password) > 7:
if lowerCheck.search(password):
if upperCheck.search(password):
if digitCheck.search(password):
if charCheck.search(password):
print('Password accepted')
break
print('Please enter a password. It must contain both UPPERCASE and '
'lowercase letters, have at least one digit and one special '
'character [!@#$%^&*_-+=?]. Your password must also be no less '
'than eight [8] characters long')
passCheck()
'''
testPasslist= ([r'9!Products!Taken!2',
'8%Broke%Neighbor%6',
'8:Members:Southern:9',
'8&Planet&Home&7',
'0;Industry;Wheels;2',
'1@Inch@Plane@6',
'4?Chance?Science?9',
'4_Spent_Round_4',
'5/August/Head/2',
'3/Distance/Montana/8'])
'''