SA-MP Forums

SA-MP Forums (
-   Scripting Help (
-   -   Comparing two strings (

addys1 19/05/2017 08:42 PM

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?


                    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;
                        SendClientMessage(playerid, -1, "Wrong Passwd");
                        return 1;

Thanks for help!

Aly 19/05/2017 08:49 PM

Re: Comparing two strings
Can you show us the DIALOG_REGISTER?

CheezIt 20/05/2017 01:48 AM

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.

All times are GMT. The time now is 02:50 AM.

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