-
Notifications
You must be signed in to change notification settings - Fork 0
/
strong_password.py
40 lines (36 loc) · 1.12 KB
/
strong_password.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
def minimumNumber(n, password):
minimum_chars = 0
new_length = n
numbers = "0123456789"
lower_case = "abcdefghijklmnopqrstuvwxyz"
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
special_characters = "!@#$%^&*()-+"
hasLower=False
hasUpper=False
hasSpecial=False
hasDigit=False
for i in password:
if i in list(numbers):
hasDigit=True
elif i in list(lower_case):
hasLower=True
elif i in list(upper_case):
hasUpper=True
elif i in list(special_characters):
hasSpecial=True
while new_length < 6 or hasLower==False or hasUpper==False or hasSpecial==False or hasDigit==False:
if hasLower == False:
minimum_chars+=1
hasLower=True
elif hasUpper == False:
minimum_chars+=1
hasUpper=True
elif hasSpecial == False:
minimum_chars+=1
hasSpecial=True
elif hasDigit == False:
minimum_chars+=1
hasDigit=True
else: minimum_chars+=1
new_length+=1
return minimum_chars