udb_hash to whirlpool hash problem
#1

hi guys, I'm trying to change from udb_hash to whirlpool after my gamemode is converted dini+dudb to Y_INI.

pawn Код:
if(udb_hash(inputtext) != PlayerInfo[playerid][Password]) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Wrong Password!\nPlease enter correct password","Login","Disconnect");
How to change it to whirlpool? Here's my ondialogresponse (login)

pawn Код:
if(dialogid == DIALOG_LOGIN)
{
    if(!response) Kick(playerid);
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    if(strlen(inputtext) == 0) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Invalid Password!\nPlease enter correct password","Login","Leave");
            if (fexist(UserPath(playerid)))
            {
                LoadData(playerid);
                if(udb_hash(inputtext) != PlayerInfo[playerid][Password]) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Wrong Password!\nPlease enter correct password","Login","Disconnect");
                else
                {
                IsPlayerLogged[playerid] = 1;
        //      SetPlayerMoney(playerid, dini_Int(file, "Money"));
                SetPlayerMoney(playerid, PlayerInfo[playerid][Money]);
        //      SetPlayerScore(playerid, dini_Int(file, "Score"));
                SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
        //      PlayerSkin[playerid] = dini_Int(file,"Skin");
                PlayerSkin[playerid] = PlayerInfo[playerid][Skin];
        //      SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
                SetPlayerWantedLevel(playerid, PlayerInfo[playerid][WantedLevel2]);
                SendClientMessage(playerid, GREY, "You are now logged in. Your status will be saved on your logout.");
                SendClientMessage(playerid, COLOR_GREEN, "Continuing current life...");
                GameTextForPlayer(playerid, "~r~Logged In!", 3000, 1);
                }
            }
}
return 0;
}
Reply
#2

pawn Код:
// Load the password before.
// PlayerInfo[playerid][Password] should be string and be in the enum:

// Password[ 129 ],

new
    buf[ 129 ]
;
WP_Hash( buf, sizeof( buf ), inputtext );
if( !strcmp( buf, PlayerInfo[ playerid ][ Password ], false ) )
{
    // Correct password
}
else
{
    // wrong password
}
Do the same on register.
pawn Код:
new
    buf[ 129 ]
;
WP_Hash( buf, sizeof( buf ), inputtext );
And save the buf.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
// Load the password before.
// PlayerInfo[playerid][Password] should be string and be in the enum:

// Password[ 129 ],

new
    buf[ 129 ]
;
WP_Hash( buf, sizeof( buf ), inputtext );
if( !strcmp( inputtext, PlayerInfo[ playerid ][ Password ], false ) )
{
    // Correct password
}
else
{
    // wrong password
}
Do the same on register.
pawn Код:
new
    buf[ 129 ]
;
WP_Hash( buf, sizeof( buf ), inputtext );
And save the buf.
Well that seriously made me confused and dizzy. Btw heres my whole dialog register & login.


pawn Код:
new file[128];
new name[MAX_PLAYER_NAME];
new Register[250];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
if(dialogid == DIALOG_REGISTER)
{
    if(!response) Kick(playerid);
    {
    if(strlen(inputtext) == 0) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Invalid Password\nPlease enter correct password!","Register","Disconnect");
    if(!fexist(file))
    {
/*          dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Money", 2500);
        dini_IntSet(file, "Score", 1);
        dini_IntSet(file, "Bank", 1000);
        dini_IntSet(file, "RobSkill", 1);
        dini_IntSet(file, "TerSkill", 1);
        dini_IntSet(file, "WantedLevel", 0);
        dini_IntSet(file, "Jail", 0);
        dini_IntSet(file, "RentalOwner", 0);
        dini_IntSet(file, "Drugs", 0);
        dini_IntSet(file, "C4", 0);
        dini_IntSet(file, "Skin", -1);*/

       
        new hashpass[129];
        WP_Hash(hashpass,sizeof(hashpass),inputtext);
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
        INI_WriteInt(File, "Password",hashpass);
        INI_WriteInt(File, "Money", 2500);
        INI_WriteInt(File, "Score", 1);
        INI_WriteInt(File, "Bank", 1000);
        INI_WriteInt(File, "RobSkill", 1);
        INI_WriteInt(File, "TerSkill", 1);
        INI_WriteInt(File, "WantedLevel", 0);
        INI_WriteInt(File, "Jail", 0);
        INI_WriteInt(File, "RentalOwner", 0);
        INI_WriteInt(File, "Drugs", 0);
        INI_WriteInt(File, "C4", 0);
        INI_WriteInt(File, "Skin", -1);
        INI_WriteInt(File, "CopP", 0);
        INI_WriteInt(File, "FBIP", 0);
        INI_WriteInt(File, "SWATP", 0);
        INI_WriteInt(File, "ArmyP", 0);
        INI_WriteInt(File, "MedicP", 0);
        INI_Close(File);
           
           
        format(Register,sizeof(Register),"Thanks for registering!\nYou may now login.",name);
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",Register,"Login","Leave");
        GameTextForPlayer(playerid, "~r~Registered!", 3000, 1);
    }
    }
}
if(dialogid == DIALOG_LOGIN)
{
    if(!response) Kick(playerid);
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    if(strlen(inputtext) == 0) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Invalid Password!\nPlease enter correct password","Login","Leave");
            if (fexist(UserPath(playerid)))
            {
                LoadData(playerid);
                if(udb_hash(inputtext) != PlayerInfo[playerid][Password]) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Wrong Password!\nPlease enter correct password","Login","Disconnect");
                else
                {
                IsPlayerLogged[playerid] = 1;
        //      SetPlayerMoney(playerid, dini_Int(file, "Money"));
                SetPlayerMoney(playerid, PlayerInfo[playerid][Money]);
        //      SetPlayerScore(playerid, dini_Int(file, "Score"));
                SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
        //      PlayerSkin[playerid] = dini_Int(file,"Skin");
                PlayerSkin[playerid] = PlayerInfo[playerid][Skin];
        //      SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
                SetPlayerWantedLevel(playerid, PlayerInfo[playerid][WantedLevel2]);
                SendClientMessage(playerid, GREY, "You are now logged in. Your status will be saved on your logout.");
                SendClientMessage(playerid, COLOR_GREEN, "Continuing current life...");
                GameTextForPlayer(playerid, "~r~Logged In!", 3000, 1);
                }
            }
Reply
#4

Change the Password in the enum to
pawn Код:
Password[ 129 ]
On loading:
pawn Код:
INI_String("Password", PlayerInfo[ playerid ][ Password ], 129);
pawn Код:
new file[128];
new name[MAX_PLAYER_NAME];
new Register[250];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
if(dialogid == DIALOG_REGISTER)
{
    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Invalid Password\nPlease enter correct password!","Register","Disconnect");
    if(!fexist(file))
    {
        /*          dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Money", 2500);
        dini_IntSet(file, "Score", 1);
        dini_IntSet(file, "Bank", 1000);
        dini_IntSet(file, "RobSkill", 1);
        dini_IntSet(file, "TerSkill", 1);
        dini_IntSet(file, "WantedLevel", 0);
        dini_IntSet(file, "Jail", 0);
        dini_IntSet(file, "RentalOwner", 0);
        dini_IntSet(file, "Drugs", 0);
        dini_IntSet(file, "C4", 0);
        dini_IntSet(file, "Skin", -1);*/


        new hashpass[129];
        WP_Hash(hashpass,sizeof(hashpass),inputtext);
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
        INI_WriteString(File, "Password",hashpass);
        INI_WriteInt(File, "Money", 2500);
        INI_WriteInt(File, "Score", 1);
        INI_WriteInt(File, "Bank", 1000);
        INI_WriteInt(File, "RobSkill", 1);
        INI_WriteInt(File, "TerSkill", 1);
        INI_WriteInt(File, "WantedLevel", 0);
        INI_WriteInt(File, "Jail", 0);
        INI_WriteInt(File, "RentalOwner", 0);
        INI_WriteInt(File, "Drugs", 0);
        INI_WriteInt(File, "C4", 0);
        INI_WriteInt(File, "Skin", -1);
        INI_WriteInt(File, "CopP", 0);
        INI_WriteInt(File, "FBIP", 0);
        INI_WriteInt(File, "SWATP", 0);
        INI_WriteInt(File, "ArmyP", 0);
        INI_WriteInt(File, "MedicP", 0);
        INI_Close(File);


        format(Register,sizeof(Register),"Thanks for registering!\nYou may now login.",name);
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",Register,"Login","Leave");
        GameTextForPlayer(playerid, "~r~Registered!", 3000, 1);
    }
}
if(dialogid == DIALOG_LOGIN)
{
    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Invalid Password!\nPlease enter correct password","Login","Leave");
    if(fexist(UserPath(playerid)))
    {
        LoadData(playerid);
        new hashpass[129];
        WP_Hash(hashpass,sizeof(hashpass),inputtext);
        if( !strcmp( hashpass, PlayerInfo[ playerid ][ Password ], false ) )
        {
            IsPlayerLogged[playerid] = 1;
            //      SetPlayerMoney(playerid, dini_Int(file, "Money"));
            SetPlayerMoney(playerid, PlayerInfo[playerid][Money]);
            //      SetPlayerScore(playerid, dini_Int(file, "Score"));
            SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
            //      PlayerSkin[playerid] = dini_Int(file,"Skin");
            PlayerSkin[playerid] = PlayerInfo[playerid][Skin];
            //      SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
            SetPlayerWantedLevel(playerid, PlayerInfo[playerid][WantedLevel2]);
            SendClientMessage(playerid, GREY, "You are now logged in. Your status will be saved on your logout.");
            SendClientMessage(playerid, COLOR_GREEN, "Continuing current life...");
            GameTextForPlayer(playerid, "~r~Logged In!", 3000, 1);
        }
        else ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Wrong Password!\nPlease enter correct password","Login","Disconnect");
    }
}
Reply
#5

Thank you so much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)