密码强度等级

密码强度等级说明 样例的密码长度大于等于 8 个字符 得 25 分 由于该密码包含大小写字母 数字和符号 所以奖励部分得 5 分 经统计得该密码的密码强度为 25 20 20 25 5 95 分

大家好,欢迎来到IT知识分享网。

密码按如下规则进行计分,并根据不同的得分为密码进行安全等级划分。

最后的评分标准

#include<stdio.h> #include<string.h> int main(){ 
    char str[301]={ 
   '\0'}; int score1=0,score2=0,score3=0,score4=0,score5=0; int len=0,nw=0,nW=0,nd=0,ns=0; scanf("%[^\n]",str); //提取数量 for(int i=0;i<strlen(str);i++){ 
    if(str[i]>='a'&&str[i]<='z') nw++; else if(str[i]>='A'&&str[i]<='Z') nW++; else if(str[i]>='0'&&str[i]<='9') nd++; } len=strlen(str); ns=len-nw-nW-nd; //1.密码长度 if(len<=4) score1=5; else if(len>=5&&len<=7) score1=10; else score1=25; //2.字母 if(nw==0&&nW==0) score2=0; else if(nw==0||nW==0) score2=10; else if(nw!=0&&nW!=0) score2=20; //3.数字 if(nd==0) score3=0; else if(nd==1) score3=10; else score3=20; //4.符号 if(ns==0) score4=0; else if(ns==1) score4=10; else score4=25; //5.奖励 if(nw*nW*nd*ns!=0) score5=5; else if(nw*nd*ns!=0||nW*nd*ns!=0) score5=3; else if(nw*nd!=0||nW*nd!=0) score5=2; //总计 int total; total=score1+score2+score3+score4+score5; switch(total/10){ 
    case 9:printf("VERY_SECURE");break; case 8:printf("SECURE");break; case 7:printf("VERY_STRONG");break; case 6:printf("STRONG");break; case 5:printf("AVERAGE");break; } if(total>=25&&total<50) printf("WEAK"); else if(total>=0&&total<25) printf("VERY_WEAK"); } 

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/124437.html

(0)
上一篇 2025-10-07 16:45
下一篇 2025-10-07 17:10

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信