|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
是一个课后练习,我没有按照小甲鱼的方法来做,自己写了一个测试密码强度的代码,如下:
while 1:
安全等级列表 = []
code = input('the code you typed will be tested to find out its security level:')
if code == '':
print('you will have to give me sth to test')
continue
if len(code) >= 8:
安全等级列表.append('长度足八位')
if 16<len(code):
安全等级列表.append('长度足十六位')
if len(code)<8:
安全等级列表.append('长度不足八位')
if code[0] in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ':
安全等级列表.append('开头有字母')
if code.isdigit() == True:
安全等级列表.append('纯数字')
if code.isalpha() == True:
安全等级列表.append('纯字母')
for each in code:
if each in '1234567890':
安全等级列表.append('有数字')
break
for each in code:
if each in 'abcdefghijklmnopqrstuvwxyz':
安全等级列表.append('有小写')
break
for each in code:
if each in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
安全等级列表.append('有大写')
break
for each in code:
if each in """~!@#$%^&*()_+|}{:"?><=-\][';/.,""":
安全等级列表.append('有符号')
break
print(安全等级列表)
if '长度不足八位' or '纯字母' or '纯数字' in 安全等级列表:
print('安全等级低')
elif '长度足八位' and '长度足十六位' and '有符号' and '有数字' and '开头有字母' and '有小写' and '有大写' in 安全等级列表:
print('安全等级高')
elif '长度足八位' in 安全等级列表:
if '开头有字母' in 安全等级列表:
if '有大写' or '有符号' or '有小写' in 安全等级列表:
print('安全等级中')
现在问题是,无论是我怎么填一个安全等级高或者是中的密码进去,它都是说密码是低安全等级,打个比方说我写了个‘abc12345678‘,这个密码既没有纯数字也没有纯英文,怎么就返回低安全等级呢?就算我是输入’I_love_fishc.com987645123456‘这个完全符合高安全等级的密码,它还是返回低安全呢等级,烦死了。。求解!!! |
|