Whirlpool
#1

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
Reply
#2

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.
Reply
#3

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

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

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
Reply
#6

Are you saving the password with djSet?
Reply
#7

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

Bump
Reply
#9

Try mademan's one.
Reply
#10

Thats the same as mines, mines just a little bit shorter
Reply
#11

Load it as string, not integer.
Reply
#12

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

Anyone know what to do?
Reply
#14

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

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

Edit: On it, you just edited
Reply
#16

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?
Reply
#17

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;
		}
Reply
#18

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


Forum Jump:


Users browsing this thread: 2 Guest(s)