Hashing passwords - 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)
+--- Thread: Hashing passwords (
/showthread.php?tid=349410)
Hashing passwords -
MarinacMrcina - 08.06.2012
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;
}
Re: Hashing passwords -
JaTochNietDan - 08.06.2012
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.
Re: Hashing passwords -
MarinacMrcina - 08.06.2012
I have downloaded Whirpool but i don't know how to use it to hash my passwords.
Re: Hashing passwords -
DaRealShazz - 08.06.2012
Search for hash.inc
Respuesta: Re: Hashing passwords -
kirk - 08.06.2012
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.
Re: Hashing passwords -
MarinacMrcina - 09.06.2012
Ok,it hashes my passwords,how can I "re-hash" it and show the password that the player has entered to him?
Re: Hashing passwords -
[ABK]Antonio - 09.06.2012
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).
Respuesta: Re: Hashing passwords -
kirk - 09.06.2012
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.
Re: Hashing passwords -
MadeMan - 09.06.2012
You don't un-hash it, you hash the password that player entered and see if it matches with saved hash.