SA-MP Forums Archive
change pass - 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: change pass (/showthread.php?tid=598914)



change pass - GeneralAref - 18.01.2016

when i use this code for change password given me [ERORR]:You have entered incorrect password.
how to fix it?


Код:
CMD:changepass(playerid, params[])
{
	new pass1[128],pass2[128];
    if(sscanf(params,"ii",pass1,pass2)) return SendClientMessage(playerid, COLOR_RED,CmdUsageText[50]);
    if(PlayerInfo[playerid][pPass2] != strval(pass1))return SendClientMessage(playerid, COLOR_RED,"[ERORR]:You have entered incorrect password.");
	new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File,"data");
	INI_WriteInt(File,"Password",udb_hash(pass2));
	INI_WriteInt(File,"Password2",strval(pass2));
	INI_Close(File);
	new str[128];
	format(str, sizeof(str), "You have change your password to %d", pass2);
	SendClientMessage(playerid, COLOR_BLUE,str);
	return 1;
}



Re: change pass - Vince - 18.01.2016

udb_hash (a.k.a. Adler-32) is not a hashing algorithm and it is completely insecure. Stop using it. Use Whirlpool or sha2.


Re: change pass - AmigaBlizzard - 18.01.2016

First of all, you declared pass1 and pass2 as a string of length 128 chars, and while using sscanf to get them out of the command-parameters, you use them as if they were integers.

And checking if strings are equal, isn't done through "strval(string)", but you use "strcmp" for that.