|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#密码安全性检查 check.py
password = input("请输入需要检查的密码组合:")
lenght = len(password)
symbols = r'''~!@#$%^&*_=-/,.?<>;:[]{}|\()'''
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
numbers = "0123456789"
temp1 = '''高级密码要求:
1. 密码必须由数字、字母及特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)三种组合
2. 密码只能由字母开头
3. 密码长度不能低于16位
'''
temp2 = '''\t您的密码安全级别评定为:'''
temp3 ="请继续保持"
require = '''\t低级密码要求:由单纯的数字或字母组成,长度小于等于8位;
中级密码要求:由数字、字母或特殊字符任意两种组合,密码长度不能低于8位
高级密码要求:由数字、字母及特殊字符三种组合,密码只能由字母开头,密码长度不能低于16位
'''
i=0
#检查password中组成元素:
while 1:
for each in password:
if each in symbols:
i +=1
break
for each in password:
if each in alphabet:
i +=1
break
for each in password:
if each in numbers:
i +=1
break
def low_password( ):
result = temp2 +"低"
print(result)
print(temp1)
def mid_password( ):
result = temp2 +"中"
print(result)
print(temp1)
def high_password( ):
result = temp2 +"高"
print(result)
print(temp3)
while (password.isspace() or lenght == 0):
password =input( "\t密码输入错误,原因:空格或未输入。\n\t重新输入要检查的密码组合:")
lenght = len(password)
break
while (i !=1 and lenght <= 8 ) :
password =input( "\t密码输入不符合要求。"+"\n\t密码要求:\n"+require+"\n\t重新输入要检查的密码组合:")
lenght = len(password)
break
while (i ==1 and lenght >8):
password =input( "\t密码输入不符合要求。"+"\n密码要求:\n"+require+"\n\t重新输入要检查的密码组合:")
lenght = len(password)
break
if lenght <=8 and i ==1:
low_password()
break
elif i==3 and lenght > 16 and password[0] in alphabet:
high_password()
break
else:
mid_password()
break |
|