03.12.2011, 11:59
I'm using MySQL to save data and tried to hash the password using Whirlpool.
I used this code but it doesn't work. The password saved in the database is the password written by the user, it isn't crypted. Could you please help me fix it?
pawn Код:
if (strcmp(cmd, "/register", true) ==0 )
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "{DC0C0C}Los Santos: {FFFFFF}Esti deja logat.");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
/*new namestring = strfind(sendername, "_", true);
if(namestring == -1)
{
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Immigration: Your name is not acceptable.");
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Hint: Your name must be in the format Firstname_Lastname.");
Kick(playerid);
return 1;
}*/
GetPlayerName(playerid, sendername, sizeof(sendername));
//format(string, sizeof(string), "%s.ini", sendername);
new sqlaccountexists = MySQLCheckAccount(sendername);
//new File: hFile = fopen(string, io_read);
if (sqlaccountexists != 0)
{
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Immigration: There is already a citizen with that name.");
//fclose(hFile);
return 1;
}
new tmppass[64];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "USAGE: /register [password]");
return 1;
}
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
new escpass[200],buf[129];
mysql_real_escape_string(tmppass,escpass);
WP_Hash(buf,129,escpass);
OnPlayerRegister(playerid,escpass);
}
return 1;
}