-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathpassword.py
More file actions
58 lines (41 loc) · 1.24 KB
/
password.py
File metadata and controls
58 lines (41 loc) · 1.24 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
52
53
54
55
56
57
58
import re
def passtest(s):
password=''
#checks whether length is more than or equal to 6
if len(s)<6:
print "Password is less than 6 characters, hence invalid."
return
#checks for uppercase character
for i in s:
if i.isupper():
break
else:
print "Password does not contain any upper case characters, hence invalid."
return
#checks for lowercase character
for j in s:
if j.islower():
break
else:
print "Password does not contain any lower case characters, hence invalid."
return
#checks for numeric character
for k in s:
if k.isdigit():
break
else:
print "Password does not contain any numeric characters, hence invalid."
return
#checks for special character
if not re.search('\W',s):
if not re.search('_',s):
print "Password does not contain any special charcaters, hence invalid."
return
print "Password is appropriate."
password=s
return password
password=''
while not password:
print
passw=raw_input("Enter password")
password=passtest(passw)