Whirlpool not hashing
#7

Ok there is a few problems with what you've got going.
pawn Код:
new escpass[129], FinalPassword[132], passwordstring[132];
WP_Hash(passwordstring, sizeof(passwordstring), FinalPassword);
You're declaring the two arrays and then whirlpool hashing them, you should be using something like:
pawn Код:
new FinalPassword[132];
WP_Hash(FinalPassword, sizeof(FinalPassword),inputtext);
That way you're hashing the inputtext and putting the result into FinalPassword. There is also no need to escape the string after you have hashed the password because the whirlpool algorithm will not use those special characters.

So really all you need to do is change this:
pawn Код:
new escpass[129], FinalPassword[132], passwordstring[132];
WP_Hash(passwordstring, sizeof(passwordstring), FinalPassword);
mysql_real_escape_string(FinalPassword, escpass);
MySQL_Register(playerid, escpass);
To this:
pawn Код:
new FinalPassword[132];
WP_Hash(FinalPassword, sizeof(FinalPassword), inputtext);
MySQL_Register(playerid,FinalPassword);
There are still a few unexplained things, such as this:
pawn Код:
format(APlayerData[playerid][PlayerPassword], 50, "%s", inputtext);
No idea why you're storing it, unless you're using it for use later on, however that (as I am sure you know) will store the players unhashed password so you probably want to be careful what you do with that.

You can also condense down your MySQL register function now too, but if you wanted you could move the whirlpool hashing into the function instead of before calling it. Its all personal preference. (Although moving it back into the function may be a good idea as you're always going to need to hash the passwords).

pawn Код:
stock MySQL_Register(playerid, const passwordstring[])
{
    new query[350], pname[24], IP[16];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    GetPlayerIp(playerid, IP, 16);
    format(query, sizeof(query), "INSERT INTO PlayerData (Name, Password, Ip, PlayerLevel,Score,OFWarns) VALUES('%s', '%s','%s',0, 0, 0)", pname, passwordstring, IP);
    mysql_query(query);
    SendClientMessage(playerid, -1, "You have been registered on this server!");
    return 1;
}
That's the cleaned up code but not including the hashing in there.

As the user above also pointed out correctly, you need to change the size of the query string to be able to fit everything in there, I have changed it for you but its a fairly arbitrary value (I'm not going to count the cells even though I have little better to do).
Reply


Messages In This Thread
Whirlpool not hashing - by SomebodyAndMe - 10.07.2012, 07:34
Re: Whirlpool not hashing - by SomebodyAndMe - 10.07.2012, 08:55
Re: Whirlpool not hashing - by SomebodyAndMe - 10.07.2012, 10:53
Re: Whirlpool not hashing - by Avi57 - 10.07.2012, 11:02
Re: Whirlpool not hashing - by Hiddos - 10.07.2012, 11:04
Re: Whirlpool not hashing - by ReneG - 10.07.2012, 11:09
Re: Whirlpool not hashing - by pyrodave - 10.07.2012, 11:14
Re: Whirlpool not hashing - by SomebodyAndMe - 10.07.2012, 11:17

Forum Jump:


Users browsing this thread: 3 Guest(s)