strcmp
#1

I get an incorrect password even if the password is correct. Password's hash prints the correct output which is in the file, I think I am using strcmp wrong.

pawn Код:
case 2:
        {
            if(!response)
            {
                Kick(playerid);
            }
            else
            {
                new buf[129];
                INI_ParseFile(UserPath(playerid), "LoadUserData_%s", .bExtra = true, .extra = playerid);
                WP_Hash(buf, sizeof (buf), inputtext);
                if(strcmp(PlayerInfo[playerid][pPassword], buf, true))
                {
                    SendClientMessage(playerid, Green, "Logged");
                }
                else
                {
                    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account", "Login to your account\n\nWrong password\n\nEnter your password:", "Login", "Quit");
                }
                printf("Password: %s | %s", buf, inputtext);
                return 1;
            }
        }
Please help.
Reply
#2

strcmp returns 0 rather than 1 if the strings match.
Reply
#3

pawn Код:
if(!strcmp(PlayerInfo[playerid][pPassword], buf, false))
Reply
#4

Toreno, now it logs me in even if the password is incorrect.
Reply
#5

Код:
if(strcmp(inputtext, buf, true) == 0)
EDIT:
My fault, can you print PlayerInfo[playerid][pPassword], and check if it is encrypted/hashed.
Reply
#6

It is empty, and that piece of line didn't work.
Reply
#7

Quote:
Originally Posted by Cowboy
Посмотреть сообщение
It is empty, and that piece of line didn't work.
You have saved the hashed password into your ini account?
Reply
#8

Yes, it is written correctly and this: printf("Password: %s | %s", buf, inputtext); prints out the exact same string as in the file.
Reply
#9

But if you print this:
Код:
printf("PlayerInfo[Password]: %s", PlayerInfo[playerid][pPassword]);
Does it says that pPassword is empty?
Reply
#10

Yes, do you want me to show how I load the password?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)