Hashing passwords
#1

Hi,I want to know how can I hash my passwords since i could not find a tutorial for it.

Код:
stock Registracija(playerid,key[])
{
	new file[64];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
	format(file,sizeof(file),"/users/%s.txt",name);
	dini_Create(file);
	dini_Set(datoteka,"Password",key);
	return 1;
}
Reply
#2

There aren't any hashing functions provided with the SA-MP API or any within the PAWN language, therefore people usually write the functions themselves and release here them on the forums, most of them are not very good though as they are old out-dated hashing techniques.

You should use a plugin such as Whirlpool to get your hashing function.
Reply
#3

I have downloaded Whirpool but i don't know how to use it to hash my passwords.
Reply
#4

Search for hash.inc
Reply
#5

Quote:
Originally Posted by DaRealShazz
Посмотреть сообщение
Search for hash.inc
No.

Use whirlpool,

pawn Код:
/*
* in/out -!< buffer[] - A string, you created before, that holds the alredy hashed string.
* in - !< len - the lenght, in bytes, of the string (always 129).
* in - !< str[] - The string to be hashed, the one you want to hash.
*/

native WP_Hash(buffer[], len, const str[]);

Thats WHIRLPOOL.

Example:

pawn Код:
stock Registracija(playerid,key[])
{
    new file[129], BuffHash[129];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(file,sizeof(file),"/users/%s.txt",name);
    dini_Create(file);
        WP_Hash(BuffHash, 129, key);
    dini_Set(datoteka,"Password",BuffHash);
    return 1;
}
That should work.
Reply
#6

Ok,it hashes my passwords,how can I "re-hash" it and show the password that the player has entered to him?
Reply
#7

Quote:
Originally Posted by MarinacMrcina
Посмотреть сообщение
Ok,it hashes my passwords,how can I "re-hash" it and show the password that the player has entered to him?
You use the key string there. You can't really unhash it....tmk. If it's in a dialog for instance, you would just tell them their password using inputtext (what they entered).
Reply
#8

Quote:
Originally Posted by MarinacMrcina
Посмотреть сообщение
Ok,it hashes my passwords,how can I "re-hash" it and show the password that the player has entered to him?
You cant un-hash it.
Reply
#9

You don't un-hash it, you hash the password that player entered and see if it matches with saved hash.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)