SA-MP Forums Archive
Whirlpool registering - 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: Whirlpool registering (/showthread.php?tid=301157)



Whirlpool registering - CONTROLA - 03.12.2011

I'm using MySQL to save data and tried to hash the password using Whirlpool.

pawn Код:
if (strcmp(cmd, "/register", true) ==0 )
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 1)
            {
                SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "{DC0C0C}Los Santos: {FFFFFF}Esti deja logat.");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            /*new namestring = strfind(sendername, "_", true);
            if(namestring == -1)
            {
                SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Immigration: Your name is not acceptable.");
                SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Hint: Your name must be in the format Firstname_Lastname.");
                Kick(playerid);
                return 1;
            }*/

            GetPlayerName(playerid, sendername, sizeof(sendername));
            //format(string, sizeof(string), "%s.ini", sendername);
            new sqlaccountexists = MySQLCheckAccount(sendername);
            //new File: hFile = fopen(string, io_read);
            if (sqlaccountexists != 0)
            {
                SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Immigration: There is already a citizen with that name.");
                //fclose(hFile);
                return 1;
            }
            new tmppass[64];
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "USAGE: /register [password]");
                return 1;
            }
            strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
            new escpass[200],buf[129];
            mysql_real_escape_string(tmppass,escpass);
            WP_Hash(buf,129,escpass);
            OnPlayerRegister(playerid,escpass);
        }
        return 1;
    }
I used this code but it doesn't work. The password saved in the database is the password written by the user, it isn't crypted. Could you please help me fix it?


Re: Whirlpool registering - IstuntmanI - 03.12.2011

Change
Код:
OnPlayerRegister(playerid,escpass);
to
Код:
OnPlayerRegister(playerid,buf);
because escpass is the real password and buf is the encrypted one.


Re: Whirlpool registering - CONTROLA - 03.12.2011

Oh, yes. Didn't see! Thanks a lot.