Skip to content

Instantly share code, notes, and snippets.

@lzzy12
Created September 29, 2017 19:15
Show Gist options
  • Save lzzy12/aeb8faca0911f87ec4fa1032e2c37489 to your computer and use it in GitHub Desktop.
Save lzzy12/aeb8faca0911f87ec4fa1032e2c37489 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
string pass, verify;
int cntUpper = 0, cntLower = 0;
int cntTry = 3;
int notValid();
void input();
void verify_format(string ab, string bc);
int main()
{
for (int i = 0; i <= 50; i++)
{
cout << "*";
}
cout << endl;
cout << "Welcome to password Validator\n";
for (int g = 0; g <= 50; g++)
{
cout << "*";
}
cout << endl;
input();
cin.ignore();
return 0;
}
int notValid()
{ cout << "\nYour password is not valid\n";
if (cntTry > 0)
{
cout << "Please try again. You have " << cntTry << " chances left\n";
cntTry--;
input();
}
else
{
cout << "You reached your maximum limits. Aborting...\n";
return 0;
}
cout << "\n" << cntUpper << " " << cntLower;
}
void input() {
cout << "Enter your password : ";
getline(cin, pass);
cout << "Verify : ";
getline(cin, verify);
verify_format(pass, verify);
}
void verify_format(string ab, string bc){
if (ab != bc)
{
cout << "Password do not matches. Try again!\n";
input();
}
else cout <<"\nPass Matched\n";
for (int i = 0; i < pass.size(); i++)
{
if (isupper(pass.at(i)))
cntUpper++;
}
for (int v = 0; v < pass.size(); v++)
{
if (islower(pass.at(v)))
cntLower++;
}
if (pass.size() > 20 || pass.size() < 6 || cntUpper == 0 || cntLower == 0)
notValid();
else cout << "Password Accepted!\n";
}
@lzzy12
Copy link
Author

lzzy12 commented Oct 5, 2017

COMPILATION STATUS : 0 errors : 0 Warnings : Last compiled in 0.3 secs
Powered by, Travis bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment