def function(password):
state = True
length = len(password)
while (password.isspace() or length == 0):
password = input('您输入的密码为空(或空格),请重新输入:')
length = len(password)
if length <= 8:
long = 1
elif 8 < length < 16:
long = 2
else:
long = 3
str1 = '1,2,3,4,5,6,7,8,9'
str2 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
str3 = r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.<>'''
kind = 0
for each in password:
if each in str1:
kind += 1
break
for each in password:
if each in str2:
kind += 1
break
for each in password:
if each in str3:
kind += 1
break
while state:
print('您的密码安全级别评定为:', end='')
if long == 1 or kind == 1:
print('低')
state = False
key = 1
elif long == 3 and kind == 3 and (password[0] in str2):
print('高')
print('继续保持!')
state = False
key = 0
break
else:
print('中')
state = False
key = 1
if key:
print('当前密码等级较低!!!')
print("请按以下方式提升您的密码安全级别:\n\
\t1. 密码必须由数字、字母及特殊字符三种组合\n\
\t2. 密码只能由字母开头\n\
\t3. 密码长度不能低于16位")
import1()
else:
print('当前密码级别为高!不需要进行修改')
def import1():
a = input('请输入需要检查的密码组合:')
function(a)
import1()
|