Whirlpool Register And Login System Problem
#1

Hello,

I wanted to edit my simple hash to Whirlpool, so i did this and all was fine, but the problem that when i login with any password even if it is wrong it logs me in

And yes whirlpool hash is working fine and also i got whirlpool plugin in plugins folder and server.cfg and i installed it correctly, any help?

Enum :

pawn Code:
enum pInfo
{
    pHash[130],
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pWarns
}
new PlayerInfo[MAX_PLAYERS][pInfo];
OnDialogResponse :

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_LIGHTBLUE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                WP_Hash(PlayerInfo[playerid][pHash], 130, inputtext);
                INI_SetTag(File,"data");
                INI_WriteString(File,"Password",PlayerInfo[playerid][pHash]);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
                Block[playerid] = 0;

                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thank you for registering!","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strcmp(PlayerInfo[playerid][pHash], inputtext, true))
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    Block[playerid] = 0;
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_LIGHTBLUE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply
#2

Sorry, but I can't see any problems.
Reply
#3

Strcmp returns 0 when either string is empty. Show where you load PlayerInfo[playerid][pHash].
Still, how can their raw password ever be the same as their hashed password? Not very well thought out.
Reply
#4

Quote:
Originally Posted by Vince
View Post
Strcmp returns 0 when either string is empty. Show where you load PlayerInfo[playerid][pHash].
Still, how can their raw password ever be the same as their hashed password? Not very well thought out.
I forgot to point out that pHash is the player password... (I know it is not really very well coded cause i was tired when i made this..)

This is where i load it :

pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pHash]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
Reply
#5

Bump...
Reply
#6

Show us where you show the Login And Register Dialog.
Reply
#7

pawn Code:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Login",""COL_LIGHTBLUE"Type your password below to login.","Login","Quit");
        Block[playerid] = 1;
    }
    else
    {
        new String[200];
        new pName[24];
        GetPlayerName(playerid, pName, 24);
        format(String, 200, ""COL_LIGHTBLUE"Welcome to %s, %s!, Type your password below to register a new account.", GetServerName(), pName);
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registering", String, "Register", "");
        Block[playerid] = 1;
    }
    return 1;
}
Reply
#8

Bump..
Reply
#9

INI_Int("Password",PlayerInfo[playerid][pHash]);

There's your problem!

It should be INI_String("Password", PlayerInfo[playerid][pHash], 130);

The hash is a string, not an integer.
Reply
#10

Oh sorry, never mind,

Thank you, i will test it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)