Question about hash - 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: Question about hash (
/showthread.php?tid=453401)
Question about hash -
CloW - 24.07.2013
Is ok this?
i input pw '123bjj' then saved in my account file as '398066741'
Is possible save inputted password with y ini and how?
Re: Question about hash -
Onfroi - 24.07.2013
I think you can't, it's to protect others people private password.
Re: Question about hash -
Vanter - 25.07.2013
Yes it is possible.
under register dialog write this
pawn Код:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Player's Data");
// INI_WriteInt(File,"Password",udb_hash(inputtext)); //Instead of that
INI_WriteString(File,"Password",strlen(inputtext));
INI_Close(File);
//on login dialog
if(response)
{
if(strlen(inputtext) == PlayerInfo[playerid][pPass]) //right password
{
I didn't test it but I think it will work
Re: Question about hash -
Alternative112 - 25.07.2013
yes its possible but saving raw passwords, ESPECIALLY in .ini files, is a very very very bad idea.
https://sampforum.blast.hk/showthread.php?tid=343019
There are tutorials on the forum on how to do this. Learn how to do it and work it into your script. A small pushstart:
pawn Код:
new Buf[129], randSalt[SALT_LENGTH], combinedHash[129], saltTmp[11], Query[500], zStr[450];
randomString(randSalt, SALT_LENGTH);
format(combinedHash, sizeof(combinedHash), "%s%s", randSalt, inputtext);
//For some really weird reason, using WP_Hash makes randSalt equal to randSalt + Buf.
//We want to save what the salt originally is though, so we set it to another variable that won't get corrupted.
WP_Hash(Buf, 129, combinedHash);
printf("saltTmp is %s", saltTmp);
//If you use Linux and try to use db_get_assoc or db_get_field on ANY empty DB field the server will CRA-A-A-ASH
//There are fixes.
//You can use .inis too, this example is just to show the values that you would write.
format(Query, sizeof(Query), "INSERT INTO `Accounts` \
(`IP`, `Name`, `Password`, `Salt`) VALUES \
('%s', '%s', '%s', '%s');",
GetPlayerIPEx(playerid), playerName(playerid), Buf, saltTmp);
stock randomString(strDest[], strLen = 10) {
while(strLen--) {
strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
}