SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/05/2017, 07:42 PM   #1
addys1
Little Clucker
 
Join Date: May 2017
Posts: 5
Reputation: 0
Default Comparing two strings

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?

Code:
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!
addys1 is offline   Reply With Quote
Old 19/05/2017, 07:49 PM   #2
Aly
Huge Clucker
 
Join Date: Oct 2012
Posts: 228
Reputation: 11
Default Re: Comparing two strings

Can you show us the DIALOG_REGISTER?
Aly is offline   Reply With Quote
Old 20/05/2017, 12:48 AM   #3
CheezIt
Big Clucker
 
CheezIt's Avatar
 
Join Date: Apr 2017
Posts: 186
Reputation: 15
Default Re: Comparing two strings

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.
__________________


I like to share footage of things I find interesting, cool, funny and anything in between!
CheezIt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing two strings. nerovani Scripting Help 6 24/03/2016 11:05 AM
Comparing 2 strings using strcmp. Black Axe Scripting Help 2 20/01/2016 07:26 AM
Comparing 2 strings Aa12 Scripting Help 8 08/01/2016 05:20 PM
comparing strings HondaCBR Scripting Help 2 02/01/2012 02:15 PM
Help with comparing two strings OUL Scripting Help 3 02/11/2011 05:11 PM


All times are GMT. The time now is 10:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.