Hashpass
#1

Actually i'm trying to hash player password's the problem is sometimes it doesn't work good, i mean when trying to login it says wrong password, when player's register it works fine..
Here's my codes.

Код:
case D_REGISTER:
{
	if (response)
	{
		if(strlen(inputtext) > 18)
		{
			SendInfoMessage(playerid, 0, "8", "Password must be a maximum of 18 characters.");
			ShowRegisterDialog(playerid,D_REGISTER);
			return 1;
		}
		if(IsNull(inputtext))
		{
			ShowRegisterDialog(playerid,D_REGISTER);
			return 1;
		}
		new hashpass[129],PlayerFile[64], playername3[MAX_PLAYER_NAME];
		GetPlayerName(playerid, playername3, sizeof(playername3));
		format(PlayerFile, sizeof(PlayerFile), "Accounts/%s.ini", playername3);
		new INI:PlayerAcc = INI_Open( PlayerFile );
		WP_Hash(hashpass,sizeof(hashpass),inputtext);
		INI_WriteString(PlayerAcc,"Password",hashpass);
		INI_Close(PlayerAcc);
		Dialog(playerid,D_LOGIN,DIALOG_STYLE_PASSWORD,"{00FF6E}Log in","{F0F0F0}For security reasons, confirm your password:","Confirm","Cancel");
	}
	else
	{
		Kick(playerid);
	}
	return 1;
}
Код:
	case D_LOGIN:
	{
		if (response)
		{
			if(IsNull(inputtext))
			{
				ShowLoginDialog(playerid,D_INGRESO);
				return 1;
			}
			new string2[128], hashpass[129], playername2[MAX_PLAYER_NAME];
			INI_ParseFile(string2, "GetPlayerPass", .bExtra = true,  .extra = playerid);
			GetPVarString(playerid, "Password", hashpass, 32);
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
			if(!strcmp(hashpass, PlayerInfo[playerid][pPassword], false))
			{
				GetPlayerName(playerid, playername2, sizeof(playername2));
				format(string2, sizeof(string2), "Accounts/%s.ini", playername2);
				INI_ParseFile(string2, "Character_Info", false, true, playerid, true, false );
				format(string2, sizeof(string2), "PlayersVehicles/%s.ini", playername2);
				INI_ParseFile(string2, "Vehicle_Info", false, true, playerid, true, false );
				format(string2, sizeof(string2), "PlayersToys/%s.ini", playername2);
				INI_ParseFile(string2, "Toys_Info", false, true, playerid, true, false );
				PlayerConnected(playerid);
			}
			else
			{
				ClearChatbox(playerid);
				ShowLoginDialog(playerid,D_LOGIN);
				SendInfoMessage(playerid, 0, "7", "The typed password is not valid, please try again.");
				gPlayerLogTries[playerid] += 1;
				if(gPlayerLogTries[playerid] == 3) { Kick(playerid); }
			}
		}
		else
		{
			Kick(playerid);
		}
		return 1;
	}
PlayerConnected(playerid); >> it checks the player if he's banned , and it will spawn his info
What's wrong with my codes, please answer as soon as possible

EDIT: Uhhh lol the first time i connect with my account it works good.. when i re connect it doesn't it says wrong password
Reply
#2

Oh LOL nevermind i just did.. in dialog login and it works fine

Код:
			new string2[128], hashpass[129], playername2[MAX_PLAYER_NAME];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            printf("Is \"%s\" same as \"%s\"?", hashpass, PlayerInfo[playerid][pPassword]);
			if(!strcmp(hashpass, PlayerInfo[playerid][pPassword], false))
and in the debugging first when i registered it was
Код HTML:
Is "7613293C186D851A669E1FBFB631FFCF0CC8E2850388E689BA3AFFBCB44705E021D6D593CE7C7E9A48B75068AAA02F6645F3251ABDE1C3FD0CD0A930E5220784" same as ""?
and i've reconnected and now it's

Код HTML:
Is "7613293C186D851A669E1FBFB631FFCF0CC8E2850388E689BA3AFFBCB44705E021D6D593CE7C7E9A48B75068AAA02F6645F3251ABDE1C3FD0CD0A930E5220784" same as "7613293C186D851A669E1FBFB631FFCF0CC8E2850388E689BA3AFFBCB44705E021D6D593CE7C7E9A48B75068AAA02F6645F3251ABDE1C3FD0CD0A930E5220784"?
tried multipe times it works..
Reply
#3

Good to see you have followed my advice and are now hashing your passwords. Security of player information is a very important aspect of any server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)