28.07.2013, 23:34
Ok, been confused. I've been trying to compare a Whirlpool hash from one that is in a database.
This doesn't seem to work, and it's definitely working (the hashing and getting the password). It just skips over to the
else { }
instead of the first. Which is confusing, I am putting the incorrect password.
pawn Code:
new rows, fields, currentPass[164];
cache_get_data(rows, fields);
if(rows)
{
cache_get_field_content(0, "Password", currentPass);
}
new hashedPass[129];
WP_Hash(hashedPass, sizeof(hashedPass), playerPass);
if(!strcmp(hashedPass, currentPass, false, 129))
{
new dialog[300];
format(dialog, sizeof(dialog),
"Welcome back, %s\n \
Please enter your password below",
PlayerName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,
"Logging", dialog, "Login", "Cancel");
print("Incorrect");
}
else
{
new query[300];
format(query, sizeof(query), "SELECT * FROM accounts WHERE `Username` = '%s'",
PlayerName(playerid));
mysql_tquery(cHandle, query, "LoginPlayer", "i", playerid);
print("Continue");
return 1;
}
else { }
instead of the first. Which is confusing, I am putting the incorrect password.