题解 | 密码强度等级

s=input()
score=0

len_score=0
if len(s)<=4:
    score+=5
elif len(s)<=7:
    score+=10
elif len(s)>=8:
    score+=25



has_upper=False
has_lower=False
has_alpha=False

num_count=0
symbol_count=0



for i in s:
    if 65<=ord(i)<=90:
        has_upper=True
        has_alpha=True
    elif ord('a')<=ord(i)<=ord('z'):
        has_lower=True
        has_alpha=True
    elif i.isdigit():
        num_count+=1
    else:
        symbol_count+=1
        
if has_lower and has_upper:
    score+=20
elif has_lower or has_upper:
    score+=10
if num_count==1:
    score+=10
elif num_count>1:
    score+=20

if symbol_count==1:
    score+=10
elif symbol_count>1:
    score+=25

if has_alpha and has_lower and has_upper and num_count>0 and symbol_count>0:
    score+=5
elif has_alpha and num_count>0 and symbol_count>0:
    score+=3
elif has_alpha and num_count>0:
    score+=2
    
if score>=90:
    print("VERY_SECURE")
elif score>=80:
    print("SECURE")
elif score>=70:
    print("VERY_STRONG")
elif score>=60:
    print("STRONG")
elif score>=50:
    print("AVERAGE")
elif score>=25:
    print("WEAK")
elif score>=0:
    print("VERY_WEAK")




全部评论

相关推荐

你背过凌晨4点的八股文么:简历挂了的话会是流程终止,像我一样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务