Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (45 loc) · 1.37 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (45 loc) · 1.37 KB
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
// #include <iostream>
// #include <string>
// #include <cctype>
// using namespace as std
#include <bits/stdc++.h>
using namespace std;
void StrengthChecker(string &password) {
int score = 0;
bool IsUpper = false;
bool IsLower = false;
bool IsDigit = false;
bool IsCharacter = false;
for(char ch : password) {
if(isupper(ch)) {
IsUpper = true;
}
else if(islower(ch)) {
IsLower = true;
}
else if(isdigit(ch)) {
IsDigit = true;
}else{
IsCharacter = true;
}
}
if(IsUpper) {score++;} else{cout<<"USE UPPERCASE"<<endl;}
if(IsLower) {score++;} else{cout<<"USE LOWERCASE"<<endl;}
if(IsDigit) {score++;} else{cout<<"USE NUMBER"<<endl;}
if(IsCharacter) {score++;} else{cout<<"USE SPECIAL CHARACTERS"<<endl;}
if (password.size()<8) {
cout<<"MINIMUM LENGTH SHOULD BE 8"<<endl;
cout<<"WEAK PASSWORD"<<endl;
return;
}else{score++;}
if(score<=2) {cout<<"WEAK PASSWORD"<<endl;}
else if(score==3) {cout<<"AVERAGE PASSWORD"<<endl;}
else if(score==4) {cout<<"GOOD PASSWORD"<<endl;}
else{cout<<"STRONG PASSWORD"<<endl;}
}
int main() {
cout<<"Enter your Password:";
string password;
cin>>password;
StrengthChecker(password);
}