Whirlpool hash problem
#1

Ok guys, i almost finished converting my gm from the old and outdated dini to mysql. Everything works except a thing. Today i decided to increase account's security and based on this i made hash the player's password using Whirlpool, and i made this:

Register:

pawn Code:
stock MySQL_Register(playerid, passwordstring[])
{
    new query1[256*2], pname[24];
    new Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    WP_Hash(query1, 256*2, passwordstring);
    new RegDate[128];
    format(RegDate, 128, "%d:%d:%d - %d/%d/%d", Hour, Minute, Second, Day, Month, Year);
    new Bannedby[20];
    format(Bannedby, 20, "Not Banned");
    GetPlayerName(playerid, pname, 24);
    format(query1, sizeof(query1), "INSERT INTO playerdata (user, password, Scores, Cash, Admin, Deaths, Nopm, Muted, Vip, Warn, RegisterDate, Jailed, AdminActions, Cookies, Rank, VipTime, Class, PrototypesStolen, KillAsUsaTeam, KillAsGermanyTeam, KillAsItalyTeam, KillAsJapanTeam, KillAsMercTeam, KillAsMexicoTeam, IP) VALUES('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')", pname, passwordstring, RegDate, GetIP(playerid));
    mysql_query(query1);
    Logged[playerid] = 1;
    WindowForPlayer(playerid, "You are now ~r~registered ~w~to Battlefield War Heroes! Enjoy playing!");
    WelcomeDialog(playerid);
    new echo[130];
    new kname[24];
    GetPlayerName(playerid, kname, 24);
    format(echo,sizeof(echo),"0,3** System: %s (%d) (IP: %s) has registered a new account",pname,playerid,GetIP(playerid));
    IRC_GroupSay(gGroupID, IRC_ACHANNEL, echo);
    new admin[128];
    format(admin,sizeof(admin),"** System: %s (%d) (%s) has registered a new account.",pname,playerid,GetIP(playerid));
    SendMessageToAdmins(LIGHTBLUE,admin);
    new txd[128];
    format(txd,sizeof(txd),"%s (%d) (IP: %s) registered a new account",pname,playerid,GetIP(playerid));
    TextDrawSetString(RegTxd, txd);
    new welcome[130];
    format(welcome, sizeof(welcome), "Welcome to Battlefield War Heroes, ~r~%s! Type ~r~/rules ~w~and ~r~/cmds ~w~for server info.",pname);
    GameTextForPlayer(playerid,welcome,6000,4);
    return 1;
}
Login:

pawn Code:
stock MySQL_Login(playerid)
{
    new query2[650], pname[24], savingstring[20];
    WP_Hash(query2, 650, savingstring);
    GetPlayerName(playerid, pname, 24);
    format(query2, sizeof(query2), "SELECT Scores, Cash, Admin, Deaths, Nopm, Muted, Vip, Warn, RegisterDate, Jailed, AdminActions, Cookies, Rank, VipTime, Class, PrototypesStolen, KillAsUsaTeam, KillAsGermanyTeam, KillAsItalyTeam, KillAsJapanTeam, KillAsMercTeam, KillAsMexicoTeam FROM playerdata WHERE user = '%s'", pname);
    mysql_query(query2);
    mysql_store_result();
    while(mysql_fetch_row_format(query2,"|"))
    {
        mysql_fetch_field_row(savingstring, "Scores"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Cash"); MoneyGiven[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Admin"); PlayerInfo[playerid][Admin] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Deaths"); PlayerInfo[playerid][Deaths] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Nopm"); PlayerInfo[playerid][Nopm] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Muted"); PlayerInfo[playerid][Muted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Vip"); PlayerInfo[playerid][Vip] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Warn"); PlayerInfo[playerid][Warn] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "RegisterDate"); PlayerInfo[playerid][RegisterDate] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Jailed"); PlayerInfo[playerid][Jailed] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "AdminActions"); PlayerInfo[playerid][AdminActions] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Cookies"); PlayerInfo[playerid][Cookies] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Rank"); PlayerInfo[playerid][Rank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "VipTime"); PlayerInfo[playerid][VipTime] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Class"); PlayerInfo[playerid][Class] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "PrototypesStolen"); PlayerInfo[playerid][PrototypesStolen] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Exp"); PlayerInfo[playerid][Exp] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Duty"); PlayerInfo[playerid][Duty] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "KillAsUsaTeam"); PlayerInfo[playerid][KillAsUsaTeam] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "KillAsGermanyTeam"); PlayerInfo[playerid][KillAsGermanyTeam] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "KillAsItalyTeam"); PlayerInfo[playerid][KillAsItalyTeam] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "KillAsJapanTeam"); PlayerInfo[playerid][KillAsJapanTeam] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "KillAsMercTeam"); PlayerInfo[playerid][KillAsMercTeam] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "KillAsMexicoTeam"); PlayerInfo[playerid][KillAsMexicoTeam] = strval(savingstring);
    }
    mysql_free_result();
    JustLogged[playerid] = 1;
    Logged[playerid] = 1;
    UpdateStatsTextdraw(playerid);
    SendClientMessage(playerid,red,"------------------------------------------------------");
    new playername3[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername3, sizeof(playername3));
    new string[200],stringg[200];
    format(string,sizeof(string),"* System: Welcome back {F70505}%s (%d) {FFFFFF} - Your stats have been restored.",playername3,playerid);
    format(stringg,sizeof(stringg),"* Level: {F70505}%d {FFFFFF} - Score: {F70505} %d {FFFFFF} - Exp: {F70505}%d {FFFFFF}- CSCash: {F70505} %i -",PlayerInfo[playerid][Admin],PlayerInfo[playerid][Scores],PlayerInfo[playerid][Exp],GetPlayerMoney(playerid));
    SCM(playerid,-1,string);
    SCM(playerid,-1,stringg);
    SendClientMessage(playerid,red,"------------------------------------------------------");


    return 1;
}
The problem is: The registration works, i get registered correctly and the player table is created, but when i login, even if i use the correct password, it gives me "Wrong password". So i guess is a problem related to the reading of the hashed password. Any way to fix?
Reply


Messages In This Thread
Whirlpool hash problem - by Face9000 - 04.01.2014, 21:20
Re: Whirlpool hash problem - by RedFusion - 04.01.2014, 21:28
Re: Whirlpool hash problem - by Face9000 - 04.01.2014, 21:36
Re: Whirlpool hash problem - by RedFusion - 04.01.2014, 21:42
Re: Whirlpool hash problem - by Face9000 - 04.01.2014, 21:44
Re: Whirlpool hash problem - by RedFusion - 04.01.2014, 21:47
Re: Whirlpool hash problem - by Konstantinos - 04.01.2014, 21:50
Re: Whirlpool hash problem - by Face9000 - 04.01.2014, 21:59
Re: Whirlpool hash problem - by Konstantinos - 04.01.2014, 22:08
Re: Whirlpool hash problem - by Face9000 - 04.01.2014, 22:11
Re: Whirlpool hash problem - by Patrick - 04.01.2014, 22:14
Re: Whirlpool hash problem - by Konstantinos - 04.01.2014, 22:15
Re: Whirlpool hash problem - by Face9000 - 04.01.2014, 22:16
Re: Whirlpool hash problem - by Patrick - 04.01.2014, 22:18
Re: Whirlpool hash problem - by Konstantinos - 04.01.2014, 22:19
Re: Whirlpool hash problem - by Face9000 - 04.01.2014, 22:24

Forum Jump:


Users browsing this thread: 1 Guest(s)