I'm having some trouble with a password validation program, I have the basics taken care of but I can't figure out where to go next. The details for the program are as follows:
Create a .cpp program that verifies the strength of a password that a user is entering is strong (complex/secure) enough. In the main area of the program, prompt the user to enter a password. Then, call a function, passing into it the password that they entered.
In the function, use whatever .cpp commands or built-in functions are available to ensure:
a. The password is at least 8 characters in length.
b. The password is mixed case (upper and lower).
c. You have at least one of these valid special characters in your password:
$ ! @ % ^ & * #
The function will determine if the password is strong enough and then output the correct message. Here is a sample run and output from the program:
First Run:
Enter a password: thisis
Your password length is too short. Please choose a password that is at least 8 characters long.
Your password is not a mixed case. Please choose a password with mixed case.
You do not have a valid special character in your password. Please add at least one special character.
Second Run:
Enter a password: thisismypassword
Your password is not a mixed case. Please choose a password with mixed case.
You do not have a valid special character in your password. Please add at least one special character.
Third Run:
Enter a password: Thisismypassword
You do not have a valid special character in your password. Please add at least one special character.
Fourth Run:
Enter a password: thisis!myPassWORD
Thank you. Your password is valid
the following is the code I have written so far:
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
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
//Declaration Block
char userPassword;
//User Input Block
cout << "Please enter your password: ";
cin >> userPassword;
//Processing Block
if (userPassword != 8)
{
cout << "Your password is not long enough, please enter a password that is at least eight characters long " << endl;
}
else
system("pause");
return 0;
}
|