I need help with Whirlpool and Y_INI
#1

Hi all,
I've created a simple register system using Y_INI and Whirlpool.
When i try to register it register my account but when i try to login it says wrong password.
Please help me. here's code:
pawn Код:
case DIALOG_LOGIN: ShowPlayerDialog( playerid, DIALOG_LOGIN2, DIALOG_STYLE_INPUT, "Password","Please write your current password.","Login", "Kick"),
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
case DIALOG_LOGIN2:
{
    if (!response) return Kick(playerid);
    if (response)
    {
        if (strlen(inputtext) == 0)
        return ShowPlayerDialog(playerid, DIALOG_LOGIN2, DIALOG_STYLE_INPUT, "Password","Error!\n{FFFFFF}Please write your current password.","Login", "Kick");
        new PlayerFile[13 + MAX_PLAYER_NAME], Password[20 + 1];
        format( PlayerFile , sizeof PlayerFile, UserData, Encode( pName( playerid ) ) );
        INI_ParseFile( PlayerFile, "ParsePlayerPass", false, true, playerid );
        GetPVarString( playerid, "pPass", Password, sizeof Password );
        new buf[145];
        WP_Hash(buf, sizeof(buf), Password);
        if(strcmp(Password, buf, false) == 0)
        {
            SetPVarInt( playerid, "Logged", 1 );
            format( PlayerFile , sizeof PlayerFile, UserData, Encode( pName( playerid ) ) );
            INI_ParseFile( PlayerFile, "LoadUser", false, true, playerid, true, false );
            SendClientMessage(playerid, -1, ""COL_RED"ACCOUNT: "COL_BLUE"You are now "COL_ORANGE"Registered"COL_BLUE", and have been "COL_ORANGE"Automaticaly "COL_BLUE"logged in");
        }
        else ShowPlayerDialog(playerid, DIALOG_LOGIN2, DIALOG_STYLE_INPUT, "Wrong password...", "Wrong password!\n{FFFFFF}Please try again.", "Login", "Kick");
    }
}
Sorry for my bad english.
Reply
#2

Try to change this:

pawn Код:
if(strcmp(Password, buf, false) == 0)
to this:

pawn Код:
if(strcmp(Password, buf) == true)
Reply
#3

Or:
pawn Код:
if(!strcmp(Password,buf,false))
Btw 129 is enough for the buffed string.
Reply
#4

The size of "Password" which is 20+1 (21) has to be enlargened to 129... Therefore the length of the password is bigger to fit the hashed pw

Change it to this:

pawn Код:
new Password[129];
Instead of

pawn Код:
new Password[20 + 1];
Reply
#5

So it should look like this ?

pawn Код:
WP_Hash(buf, sizeof(buf), inputtext);
        if(strcmp(Password, inputtext) == true)
Reply
#6

please ******, write tutorial for this, I have the same problem, peoples tell me to use dini and dudb but I wan't Y_INI and Whirlpool
Reply
#7

Like this:
pawn Код:
case DIALOG_LOGIN: ShowPlayerDialog( playerid, DIALOG_LOGIN2, DIALOG_STYLE_INPUT, "Password","Please write your current password.","Login", "Kick"),
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        case DIALOG_LOGIN2:
        {
            if (!response) return Kick(playerid);
            if (response)
            {
                if (strlen(inputtext) == 0)
                    return ShowPlayerDialog(playerid, DIALOG_LOGIN2, DIALOG_STYLE_INPUT, "Password","Error!\n{FFFFFF}Please write your current password.","Login", "Kick");
                new PlayerFile[13 + MAX_PLAYER_NAME], Password[129];
                format( PlayerFile , sizeof PlayerFile, UserData, Encode( pName( playerid ) ) );
                INI_ParseFile( PlayerFile, "ParsePlayerPass", false, true, playerid );
                GetPVarString( playerid, "pPass", Password, sizeof Password );
                new buf[145];
                WP_Hash(buf, sizeof(buf), inputtext);
                if(strcmp(Password, inputtext) == true)
                {
                    SetPVarInt( playerid, "Logged", 1 );
                    format( PlayerFile , sizeof PlayerFile, UserData, Encode( pName( playerid ) ) );
                    INI_ParseFile( PlayerFile, "LoadUser", false, true, playerid, true, false );
                    SendClientMessage(playerid, -1, ""COL_RED"ACCOUNT: "COL_BLUE"You are now "COL_ORANGE"Registered"COL_BLUE", and have been "COL_ORANGE"Automaticaly "COL_BLUE"logged in");
                }
                else ShowPlayerDialog(playerid, DIALOG_LOGIN2, DIALOG_STYLE_INPUT, "Wrong password...", "Wrong password!\n{FFFFFF}Please try again.", "Login", "Kick");
            }
        }
If not then please correct the code.
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
pawn Код:
if(strcmp(Password, inputtext) == true)
That should check "buf", not "inputtext".
Still Same problem ;(. it says wrong password.
Reply
#9

Change:
pawn Код:
new buf[145];
WP_Hash(buf, sizeof(buf), Password);
to
pawn Код:
new buf[145];
WP_Hash(buf, sizeof(buf), inputtext);
Reply
#10

Not working...

Please help me Please!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)