Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- bool validatePass(char *);
- int main()
- {
- char password(100);
- bool exit = false;
- // Name of App.
- cout << "Password Verification Program: " << endl << endl;
- while (exit == false)
- {
- cout << endl << "Enter a Password: ";
- cin.getline(password,99);
- exit = validatePass(password);
- }
- cout << endl << "Password Accepted" << endl;
- //Password Validation Function
- bool validatePass(char *array);
- {
- int length, upCount=0, lowCount=0, digCount=0;
- length = strlen(array);
- if (length<6)
- {
- cout << "Password must be at least 6 characters in length";
- return false;
- }
- for (int i=0; i<length; i++)
- {
- if(isupper(array[i]) > 0)
- upCount++;
- if(islower(array[i]) > 0)
- lowCount++;
- if(isdigit(array[i]) > 0)
- digCount++;
- }
- if(upCount == 0)
- {
- cout << endl << "Password must contain at least 1 UPPER case character";
- return false;
- }
- if(lowCount == 0)
- {
- cout << endl << "Password must contain at least 1 LOWER case character";
- return false;
- }
- if(digCount == 0)
- {
- cout << endl << "Password must contain at least ONE numeric chracter";
- return false;
- }
- return true;
- }
Add Comment
Please, Sign In to add comment