Comparing two strings
#1

Hi, I've seen a lot of topics on this topic, but none of them could help me in any way. I would like to compare the encrypted password from the database with the encrypted text entered in the dialog. Someone knows something?

Код:
case DIALOG_LOGIN:
		{
		    new Hash2[80];
			new rows2, fields2;
            mysql_query(mySQLconnection, sprintf("SELECT haslo FROM ipb_characters WHERE char_name = '%s' LIMIT 1", pInfo[playerid][player_name]));
			cache_get_data(rows2, fields2);
			format(Hash2, sizeof(Hash2), "%s%s", MD5_Hash(gInfo[playerid][global_salt]), MD5_Hash(inputtext));
			format(Hash2, sizeof(Hash2), "%s", MD5_Hash(Hash2));
			if(!strcmp(Hash2,rows2, true))
			{
			SendClientMessage(playerid, -1, "Nice Passwd, good boy");
			gInfo[playerid][global_logged] = true;
			OnPlayerLoginHere(playerid);
			}
			else
			{
			SendClientMessage(playerid, -1, "Wrong Passwd");
			}
			return 1;
}
Thanks for help!
Reply
#2

Can you show us the DIALOG_REGISTER?
Reply
#3

Strcmp (native function) is used to compare strings (or more precisely, 2 strings). Do the same procedure on "inputtext" (var returned by OnDialogResponse, being the inputted text in the dialog) and compare it to the hash provided by an SQL statement (load the hash and use the variable/array to compare instead of a repetitive query).

Also, a hash isn't a form of encryption. Hashes are one way.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)