20.10.2011, 10:38
Well, I am busy with a register system. I always used this method with MYSQL, and it always worked, until I used Whirlpool hash.
This is my code to check if the two passwords match:
As you can see I print the password the player entered, and the password which gets stored by MYSQL.
When I register with the password "lol", it returns this password:
So, when I login it prints the following:
As you can see it matches, but STRCMP says it doesn't (it goes to the wrong password part).
I've tried many methods to compare the passwords out of frustration, but no results.
I hope you can help me.
This is my code to check if the two passwords match:
pawn Код:
stock PlayerLogin(playerid, password[])
{
new query[256];
WP_Hash(password, 129, password);
printf("Login: %s", password);
format(query, sizeof(query), "SELECT `password` FROM `users` WHERE `username` = '%s'", PlayerName(playerid));
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row_format(query))
{
sscanf(query, "s[129]", PlayerInfo[playerid][pPassword]);
}
mysql_free_result();
printf("Password: %s", PlayerInfo[playerid][pPassword]);
// if(!strcmp(password, PlayerInfo[playerid][pPassword], false))
if (strcmp(password, PlayerInfo[playerid][pPassword]) == 0)
// if(!strcmp(password, PlayerInfo[playerid][pPassword]))
{
SendClientMessage(playerid, -1, "You are now logged in.");
StoreAccountInfo(playerid);
SetPlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
pLogged[playerid] = 1;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: Incorrect password!");
format(query, sizeof(query), "{FFFFFF}Welcome {008B8B}%s, \n{FFFFFF}Your account exists, please login.", PlayerName(playerid));
ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_INPUT, "Login", query, "Login", "Cancel");
return 0;
}
}
When I register with the password "lol", it returns this password:
Код:
22FB46E1955A8AEB31C59D79D887D02AF2D1BC4524E85AAFA2455CC78BC0147B10DD477201D147E2F5CA910BB43D982320478B9D179DDDE85F4806497FE2EE68
Код:
Login: 22FB46E1955A8AEB31C59D79D887D02AF2D1BC4524E85AAFA2455CC78BC0147B10DD477201D147E2F5CA910BB43D982320478B9D179DDDE85F4806497FE2EE68 Password: 22FB46E1955A8AEB31C59D79D887D02AF2D1BC4524E85AAFA2455CC78BC0147B10DD477201D147E2F5CA910BB43D982320478B9D179DDDE85F4806497FE2EE68
I've tried many methods to compare the passwords out of frustration, but no results.
I hope you can help me.