10.07.2012, 07:34
I am using whirlpool to hash my passwords, but in some reasons it doesnt work properly, it doesn't hash.
It just updates it without anything in.
My code:
Can someone help me out of this?
It just updates it without anything in.
My code:
pawn Код:
/* this is where it registers, i've commented the has line since I putted it somewhere else */
stock MySQL_Register(playerid, passwordstring[])
{
new query[200], pname[24], IP[16], HashPW[129], FinalPassword[132];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
GetPlayerIp(playerid, IP, 16);
//mysql_real_escape_string(passwordstring, HashPW);
//WP_Hash(passwordstring, sizeof(passwordstring), FinalPassword);
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;
}
/* here is the register dialog */
Dialog_Register(playerid, response, inputtext[])
{
new file[100], Name[MAX_PLAYER_NAME]; // Setup local variables
GetPlayerName(playerid, Name, sizeof(Name)); // Get the playername
format(file, sizeof(file), PlayerFile, Name); // Construct the complete filename for this player's account
switch (response) // Check which button was clicked
{
case 1: // Player clicked "Register"
{
// Check if the player entered a password
if(strlen(inputtext)>0)
{
// Store the password
format(APlayerData[playerid][PlayerPassword], 50, "%s", inputtext);
// Create the file and save default data to it, then reload it (so all data is put into the correct place
new escpass[129], FinalPassword[132], passwordstring[132];
WP_Hash(passwordstring, sizeof(passwordstring), FinalPassword);
mysql_real_escape_string(FinalPassword, escpass);
MySQL_Register(playerid, escpass);
// Send a message to the client to inform him that his account has been registered
SendClientMessage(playerid, 0xFFFFFFFF, TXT_AccountRegistered);
APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
Kick(playerid);
}
}
case 0: // Player clicked "Cancel"
{
// Show a message that the player must be registered to play on this server
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustRegister);
// Kick the player
Kick(playerid);
}
}
return 1;
}