array must be indexed (variable "inputtext") - udb hash
#1

I searched around for this and I couldn't really figure out what is going on. Assistance would be appreciated.


Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch( dialogid )
	{
	    case DIALOG_REGISTER:
	    {
	        if (!response) return Kick(playerid);
	        if (response)
	        {
	            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Register",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register an account.","Register","Quit");
	            new INI:File = INI_Open(UserPath(playerid));
	            INI_SetTag(File,"data");
	            INI_WriteInt(File,"Password",udb_hash(inputtext));
	            INI_WriteInt(File,"Cash",0);
	            INI_WriteInt(File,"Admin",0);
	            INI_WriteInt(File,"Mod",0);
	            INI_WriteInt(File,"VIP",0);
	            INI_WriteInt(File,"Kills",0);
				INI_WriteInt(File,"Deaths",0);
				INI_WriteInt(File,"Level",0);
				INI_WriteInt(File,"Hours",0);
				INI_Close(File);
				
				SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
				SpawnPlayer(playerid);
				ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Relog to save your stats!","Ok","");
			}
		}
		case DIALOG_LOGIN:
		{
			if( !response ) return Kick(playerid);
			if( response )
			{
				if(udb_hash(inputtext == PlayerInfo[playerid][pPass]))
				{
					INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
					GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
					ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
				}
				else
				{
					ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password. \n"COL_WHITE"Type your password below to login.","Login","Quit");
				}
				return 1;
			}
		}
	}
	return 1;
}

My udb hash is here

Код:
//Hasher
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
Thanks in advance.
Reply
#2

Haven't used udb_hash or nothing but I believe this is the correct way of doing it:


pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
Reply
#3

Well you shouldn't be using it anyway. Particularly in the case of passwords. udb_hash is the equivalent of Adler32. This is a checksum algorithm (i.e. it is used to verify integrity) rather than a hashing algorithm. It can be cracked in seconds. It is not secure at all. Use something more secure like Whirlpool or SHA2 (in the case of MySQL) with a salt.
Reply
#4

pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
You forgot a bracket right there.
What you wrote.
pawn Код:
if(udb_hash(inputtext == PlayerInfo[playerid][pPass])) // << This bracket shouldn't be at the end.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)