SA-MP Forums Archive
Whirlpool - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Whirlpool (/showthread.php?tid=266425)



Whirlpool - Wesley221 - 04.07.2011

Hey guys,
How can i check if the WP_Hashed password equals to the inputtext you enter in the inputtext of a dialog?
Ive tried it like this:
pawn Code:
new buf[129]; pass = WP_Hash(buf, sizeof buf, inputtext);
if(pass == djInt(file, "Password"))
But with this i can just login with any password. Im kinda new to whirlpool, so i dont really know how to use it.
Any help is appreciated!
~Wesley


Re: Whirlpool - Vince - 04.07.2011

You'll have to change your whole script, as Whirlpool doesn't generate just integer hashes (like udb_hash does), but large strings. So you cannot use djInt to retrieve the password. Furthermore, strings needs to be compared with strcmp.


Re: Whirlpool - Wesley221 - 04.07.2011

So how would i do this? I just started with a new filterscript, so wont be a pain in the ass i think


Re: Whirlpool - MadeMan - 04.07.2011

pawn Code:
new buf[129];
WP_Hash(buf, sizeof buf, inputtext);
if(strcmp(buf, dj(file, "Password")) == 0)



Re: Whirlpool - Wesley221 - 05.07.2011

pawn Code:
new buf[129];
WP_Hash(buf, sizeof buf, inputtext);
if(!strcmp(buf, dj(file, "Password")))
So i made it like this, but still got the same problem. When i try to login with a random made password, it just logs me in


Re: Whirlpool - MadeMan - 05.07.2011

Are you saving the password with djSet?


Re: Whirlpool - Wesley221 - 05.07.2011

This is how i save the password when you register
pawn Code:
WP_Hash(buf, sizeof buf, inputtext);
djSet(file, "Password", buf);



Re: Whirlpool - Wesley221 - 05.07.2011

Bump


Re: Whirlpool - FireCat - 05.07.2011

Try mademan's one.


Re: Whirlpool - Wesley221 - 05.07.2011

Thats the same as mines, mines just a little bit shorter


Re: Whirlpool - =WoR=Varth - 05.07.2011

Load it as string, not integer.


Re: Whirlpool - Wesley221 - 06.07.2011

Take a better look before you post. I already did that


Re: Whirlpool - Wesley221 - 06.07.2011

Anyone know what to do?


Re: Whirlpool - Calgon - 06.07.2011

Could you print the password before you save it and paste the output?


Re: Whirlpool - Wesley221 - 06.07.2011

pawn Код:
WP_Hash(buf, sizeof buf, inputtext);
djSet(file, "Password", buf);
This is how it saves

Edit: On it, you just edited


Re: Whirlpool - Calgon - 06.07.2011

Sorry, I edited my post after noticing that post. Could you print the password before you use strcmp to compare it against what the user typed?


Re: Whirlpool - Babul - 06.07.2011

here you go: my password processing works fine, maybe you find some useful lines in that snippet.
remove the //commented-debug-chat-spam (showing passwords etc) lines, maybe it helps you at spotting your bug...
Код:
		case DIALOG_REGISTER:
		{
			new PassWordStringInput[24];
			new buffer[129];
			new filename[32];
			new Name[MAX_PLAYER_NAME];
			GetPlayerName(playerid,Name,sizeof(Name));
			if(response)
			{
				if(!sscanf(inputtext,"s[24]",PassWordStringInput))
				{
				//	SendClientMessage(playerid,MSGCMDS_COLOR,PassWordStringInput);
					WP_Hash(buffer,sizeof(buffer),PassWordStringInput);
				//	SendClientMessage(playerid,MSGCMDS_COLOR,buffer);
					format(filename, sizeof(filename),"userdata/%s.txt",Name);
					new File:PWFile=fopen(filename,io_readwrite);
					fwrite(PWFile,buffer);
					fclose(PWFile);
					WelcomeMessage(playerid);
				}
				else
				{
					Kick(playerid);
				}
			}
			else
			{
				Kick(playerid);
			}
			return 1;
		}
		case DIALOG_LOGIN:
		{
			new PassWordStringInput[24];
			new buffer[129];
			new readbuffer[129];
			new filename[32];
			new Name[MAX_PLAYER_NAME];
			GetPlayerName(playerid,Name,sizeof(Name));
			if(response)
			{
				if(!sscanf(inputtext,"s[24]",PassWordStringInput))
				{
				//	SendClientMessage(playerid,MSGCMDS_COLOR,PassWordStringInput);
					WP_Hash(buffer,sizeof(buffer),PassWordStringInput);
				//	SendClientMessage(playerid,MSGCMDS_COLOR,buffer);
					format(filename, sizeof(filename),"userdata/%s.txt",Name);
					new File:PWFile=fopen(filename,io_read);
					fread(PWFile,readbuffer);
					fclose(PWFile);
					if(strfind(readbuffer,buffer,false,0)==0)
					{
						WelcomeMessage(playerid);
//						SendClientMessage(playerid,MSGSUCC_COLOR,"match");
					}
					else
					{
						Kick(playerid);
					}
				}
				else
				{
					Kick(playerid);
				}
			}
			else
			{
				Kick(playerid);
			}
			return 1;
		}



Re: Whirlpool - Wesley221 - 06.07.2011

Problem is solved, the password wasnt being saved in the file. Thanks for your help guys