Help with Whirlpool
#1

Hi, i want to code my server user passwords by using Whirlpool, but i dont know how. I have downloaded Whirlpool succesfuly loaded it and put in the native.

I have tried this, but in the .ini file of a user it shows Password=0

Code:
if(dialogid == 0)
{
if(response)
{
		new name[MAX_PLAYER_NAME],file[128];
		GetPlayerName(playerid,name,sizeof(name));
		format(file,sizeof(file),"saves/user/%s.ini",name);
		dini_Create(file);
                new buffer[129];
		dini_IntSet(file,"Password",WP_Hash(buffer, sizeof(buffer), inputtext));
		format(file,sizeof(file),"{FF0000}MPG:{FFFF00} Jus uzregistruotas ir prijungtas, aciu kad pasirinkote {00FF00}MPGames {FF0000}(Password: %s)",inputtext);
		SendClientMessage(playerid,GELTONA,file);
		playerDB[playerid][authstate]=1;
		return 1;
	}
	return 1;
	}
	return 1;
}
Reply
#2

pawn Code:
WP_Hash(buffer, sizeof(buffer), inputtext);
dini_Set(file,"Password",buffer);
Reply
#3

Thanks, its coded now, and thats i big code Im going to try to login now.
Reply
#4

It writes incorrect password. I found this what do i need to change?

Code:
stock tohash(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;
}

stock CheckPass(file[],password[])
{
	if(dini_Int(file,"Password")==tohash(password)) return true;
	return false;
}
Reply
#5

pawn Code:
stock CheckPass(file[],password[])
{
    new buffer[129];
    WP_Hash(buffer, sizeof(buffer), password);
    if(strcmp(dini_Get(file,"Password"), buffer) == 0) return true;
    return false;
}
Reply
#6

Thank you, i tested everything and i can say that now the passwords are safe
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)