Hi guys! I have to write a code that checks to see if the password entered meets certain criteria and if it does not the whole function is supposed to start over. The criteria are that it must be atleast 12 characters and must have one upercase letter, one lowercase letter, one number, and one special character. I already have some of the code down but I don't know where to go from here. Any help with this would be greatly appreciated. Thanks in advance guys!!
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "password checker\n";
cout << "enter a password: ";
string password = "";
int i = 0;
bool length = false;
bool upper = false;
bool lower = false;
bool number = false;
bool special = false;
getline(cin, password);
while (length != false && upper != false && lower != false && number != false && special != false )
{
for (int i = 0; i < password.length; ++i)
{
if (password.length >= 12)
{
length = true;
}
if (password[i] >= 'a' && password[i] <= 'z')
{
lower = true;
}
if (password[i] >= 'A' && password[i] <= 'Z')
{
upper = true;
}
if (password[i] >= '0' && password[i] <= '9')
{
number = true;
}
if (password[i] == '!' || password[i] == '@' || password[i] == '#' || password[i] == '$' || password[i] == '%' || password[i] == '&' || password[i] == '^' || password[i] == '*')
{
special = true;
}
}
}
system("pause");
return 0;
}