SA-MP Forums Archive
Hashing password issue. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hashing password issue. (/showthread.php?tid=616951)



Hashing password issue. - Type-R - 13.09.2016

Hello, so i started to hash my player passwords. So when i register the password gets hashed. Now the issue comes in when i login, usually like 98% of the time everything works flawless. But there are times when i enter the password and it says, the password is incorrect. I have to reconnect, to login because it will keep on saying that my password is incorrect. Here's some code:

This is my register code for the dialogresponse:
Код:
            {
                new
					query[600];
                WP_Hash(slaptazodis[playerid], 129, inputtext);
			    new laikas = gettime();
			    new pname1[24]; //We use this variable to format our query
				GetPlayerName(playerid, pname1, 24);
    			mysql_format(mysql, query, sizeof(query), "INSERT INTO vartotojai (Vardas, Slaptazodis, Nuzudymai, Mirtys, Pinigai, Bankas, Adminas, Admin_lygis, Namas, IP, Zaidziu, XP, Siandien, Prizas, WKartai, Specialybe, Drk, pav, Dispejimai, GangXP, Masinosraktas, rangas1, rangas2, rangas3, rangas4, Kiekgauta, Kreditai, VIPtime, VIP, DYRtime, PaskutinisLankymas, PIN) VALUES('%s', '%e', 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0,'%d',0)"
//				, pname1, escpass, IP[playerid],laikas);
				, pname1, slaptazodis[playerid], IP[playerid],laikas);
				//Now let's create a new row and insert player's information in it
				mysql_tquery(mysql, query, "MySQL_Register", "i", playerid);
This is for logging in:
Код:
if(response) 
        {
            new pname[24];
            new hashpass[129];

			// Get player name
			GetPlayerName(playerid, pname, 24);
			new query[500];//, escapepass[100];
	//		mysql_real_escape_string(inputtext, escapepass);
			WP_Hash(hashpass, sizeof(hashpass), inputtext);
            if(!strcmp(hashpass, slaptazodis[playerid]))
            //if(!strcmp(escapepass, slaptazodis[playerid]) && strlen(inputtext)) //remember we have loaded player's password into this variable, pInfo[playerid][Password] earlier. Now let's use it to compare the hashed password with password that we load
	        { 
	            mysql_format(mysql, query, sizeof(query), "SELECT * FROM `vartotojai` WHERE `Vardas` = '%e' LIMIT 1", pname);
				mysql_tquery(mysql, query, "MySQL_Login", "i", playerid);
			}
			else //if the hashed password didn't match with the loaded password(pInfo[playerid][Password])
			{
                SendClientMessage(playerid, 0xFFFFFFFF, "{F81414}* Slaptazodis ivestas neteisingai!");
				ShowPlayerDialog(playerid,LOG_Dialog,DIALOG_STYLE_PASSWORD,"{A3E4FF}Prisijungimas", "{FFFFFF}Jusu ivestas slaptazodis buvo {F81414}neteisingas{FFFFFF},\n{FFFFFF}pabandykite ivesti dar karta:" ,"Prisijungti","Iseiti");
			}
I don't understand what could be causing the issue.. Any ideas? Also sorry for the mess, i don't know why its posting it like this.. I have it well indented.