Custom password validation

Hello


Last edited on
Like so:
1
2
3
4
5
6
7
8
9
bool is_valid;
do
{
    if (verify_chars(userinput))
    {is_valid = verify_pass(userinput);}
    else
    is_valid = false;
}
while(! is_valid);
I imagine you'd also want to retry if verify_chars returns false:
1
2
3
4
5
6
7
8
9
10
11
int main()
{
    char userinput[1024];
    do 
   {
       cout << "Please enter a password:\n";
       cin >> userinput;
    } while(!verify_chars(userinput) && !verify_pass(userinput));

    return 0;
}
dasda
Last edited on
yes, sorry I forgot to include the user input:
1
2
3
4
5
6
7
8
9
10
11
12
bool is_valid;
do
{
    cout << "Please enter a password:\n";
    cin >> userinput;

    if (verify_chars(userinput))
    {is_valid = verify_pass(userinput);}
    else
    is_valid = false;
}
while(! is_valid);


The reason why it still not work: Where in your program do you provide a valid password?

Maybe something like this : char password[SIZE + 1] = "Tccd-03";
Okay it works now thanks, but what if I dont want it to say "Wrong password" what would I do then
then don't verify_pass. Using tipayes solution:
1
2
3
4
5
6
7
8
9
10
11
int main()
{
    char userinput[1024];
    do 
   {
       cout << "Please enter a password:\n";
       cin >> userinput;
    } while(!verify_chars(userinput) && !verify_pass(userinput));

    return 0;
}
adasdas
Last edited on
As I stated above: just leave out verify_pass
I did that but it gave me all these errors also if I remove that then if I give it a correct password it doesn't say "Thank you, that is a valid password."
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
    char userinput[1024];
    do 
   {
       cout << "Please enter a password:\n";
       cin >> userinput;
    } while(!verify_chars(userinput));

    cout << "Thank you, that is a valid password.\n";

    return 0;
}
Topic archived. No new replies allowed.