19.05.2013, 07:31
OK, so today I've decided to use Whirlpool for password hashing in DRP. But this problem desperates me. I'm modifying and testing for one hour, but no result. The variable for the password is 129 cells lenght and the buffer too. Here, the dialogs for register and login:
Oh, and the problem: i have printed the hashed password and it's ok. But in the .ini file, the last character is missing. For example:
Any idea?
pawn Код:
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Making your account...","{FF0000}You have entered an invalid password.\n{FFFFFF}Type your password below to register a new account.","Register","Quit");
new pass[129];
WP_Hash(pass, sizeof(pass), inputtext);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File, "Password", pass);
INI_WriteInt(File, "Cash", 1000);
INI_WriteInt(File, "Bank", 25000);
INI_WriteInt(File, "Admin", 0);
INI_WriteInt(File, "Moderator", 0);
INI_WriteInt(File, "VIP", 0);
INI_WriteInt(File, "Level", 1);
INI_WriteInt(File, "Kills", 0);
INI_WriteInt(File, "Deaths", 0);
INI_WriteInt(File, "Faction", 0);
INI_WriteInt(File, "FRank", 0);
INI_WriteInt(File, "SpawnCity", 0);
INI_WriteInt(File, "Tutorial", 0);
INI_WriteInt(File, "Car", 999);
INI_WriteInt(File, "Car2", 999);
INI_WriteInt(File, "Wanted", 0);
INI_WriteInt(File, "Warns", 0);
INI_WriteInt(File, "MuteTime", 0);
INI_WriteString(File, "sRank", " ");
INI_WriteInt(File, "Job", 0);
new day, month, year;
getdate(year, month, day);
format(string, sizeof(string), "%d.%d.%d", day, month, year);
INI_WriteString(File, "Register Date", string);
INI_Close(File);
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Type your password to login.", "OK", "Quit");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Crash ( playerid );
if( response )
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "You must enter a password.", "OK", "Quit");
else
{
new password[129];
WP_Hash(password, sizeof(password), inputtext);
if(!strcmp(password, PlayerData[playerid][Pass]))
{
GivePlayerMoney(playerid, PlayerData[playerid][Cash]);
RespawnPlayer(playerid);
StopAudioStreamForPlayer(playerid);
loggedin[playerid] = 1;
}
else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","{FF0000}You have entered an incorrect password.\n{FFFFFF}Type your password below to login.","Login","Exit");
}
}
}
pawn Код:
666847E02F6C42DE55BC690A1E107B290ADC45D56AC4DE195C02AA81DF1AD4047BDD47E03793F5072C06B7EA6E6CDD6A60D42A08774214AF34937860CF5A348B//good password
666847E02F6C42DE55BC690A1E107B290ADC45D56AC4DE195C02AA81DF1AD4047BDD47E03793F5072C06B7EA6E6CDD6A60D42A08774214AF34937860CF5A348//in the .ini file