-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path密码强度等级.cpp
79 lines (74 loc) · 1.82 KB
/
密码强度等级.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <string>
using namespace std;
void Solution(string Password)
{
int countEnglihCharH = 0, countEnglihCharL = 0, countNumber = 0, countOtherChar = 0;
int len = Password.size();
for (int i = 0; i < len; i++)
{
if (Password[i] >= 'A' && Password[i] <= 'Z')
countEnglihCharH++;
else if (Password[i] >= 'a' && Password[i] <= 'z')
countEnglihCharL++;
else if (Password[i] >= '0' && Password[i] <= '9')
countNumber++;
else
countOtherChar++;
}
//
int sum = 0;
if (len <= 4) sum += 5;
else if (len >= 5 && len <= 7)
sum += 10;
else if (len >= 8)
sum += 25;
//
if (countEnglihCharH == 0 && countEnglihCharL == 0)
sum += 0;
else if ((countEnglihCharH > 0 && countEnglihCharL == 0) || (countEnglihCharH == 0 && countEnglihCharL > 0))
sum += 10;
else if (countEnglihCharH > 0 && countEnglihCharL > 0)
sum += 20;
//
if (countNumber == 0) sum += 0;
else if (countNumber == 1)
sum += 10;
else if (countNumber >= 2)
sum += 20;
//
if (countOtherChar == 0) sum += 0;
else if (countOtherChar == 1)
sum += 10;
else if (countOtherChar >= 2)
sum += 25;
//
int countEnglihChar = countEnglihCharH + countEnglihCharL;
if (countEnglihChar > 0 && countNumber > 0)
sum += 2;
else if (countEnglihChar > 0 && countNumber > 0 && countOtherChar > 0)
sum += 3;
else if (countEnglihCharH > 0 && countEnglihCharL > 0 && countNumber > 0 && countOtherChar > 0)
sum += 5;
if (sum >= 90)
cout << "VERY_SECURE" << endl;
else if (sum >= 80)
cout << "SECURE" << endl;
else if (sum >= 70)
cout << "VERY_STRONG" << endl;
else if (sum >= 60)
cout << "STRONG" << endl;
else if (sum >= 50)
cout << "AVERAGE" << endl;
else if (sum >= 25)
cout << "WEAK" << endl;
else if (sum >= 0)
cout << "VERY_WEAK" << endl;
}
int main()
{
string str;
getline(cin, str);
Solution(str);
return 0;
}