#include<iostream>
#include<string.h>
#define N 10000
using namespace std;
void GetPwdSecurityLevel(char *s)
{
//cout<<"in"<<endl;
int grade = 0;
int len = strlen(s);
if(len<=4)
grade += 5;
else if(len>=5&&len<=7)
grade +=10;
else
grade += 25;
int intesum = 0,symsum = 0,lowersum = 0,uppersum = 0;
while(*s != '\0')
{
char temp = *s;
if(temp>='a'&&temp<='z')
++lowersum;
else if(temp>='A'&&temp<='Z')
++uppersum;
else if(temp>='0'&&temp<='9')
++intesum;
else if((temp>=33&&temp<=47) ||(temp>=58&&temp<=64) ||(temp>=91&&temp<=96)||(temp>=123 &&temp<=126))
{
++symsum;
}
++s;
}
if((lowersum&&!uppersum)||(uppersum&&!lowersum))
{
grade += 10;
}
else if(lowersum>0&&uppersum>0)
{
grade += 20;
}
if(intesum==1)
grade += 10;
else if(intesum>1)
grade += 20;
if(symsum==1)
grade += 10;
else if(symsum>1)
grade += 25;
int charsum = lowersum + uppersum;
if(charsum&&intesum&&!symsum)
{
grade += 2;
}
else if(charsum&&intesum&&symsum)
{
if(lowersum && uppersum)
grade += 5;
else
grade += 3;
}
//cout<<grade<<endl;
if(grade>=90)
{
cout<<"VERY_SECURE"<<endl;
}
else if(grade>=80)
{
cout<<"SECURE"<<endl;
}
else if(grade>=70)
{
cout<<"VERY_STRONG"<<endl;
}
else if(grade>=60)
{
cout<<"STRONG"<<endl;
}
else if(grade>=50)
{
cout<<"AVERAGE"<<endl;
}
else if(grade>=25)
{
cout<<"WEAK"<<endl;
}
else if(grade>=0)
{
cout<<"VERY_WEAK"<<endl;
}
}
int main()
{
char s[N];
scanf("%s",&s);
GetPwdSecurityLevel(s);
return 0;
}
华为oj 密码强度等级
最新推荐文章于 2021-02-25 09:24:54 发布