SA-MP Forums Archive
decrypting udb_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: decrypting udb_hash? (/showthread.php?tid=317847)



decrypting udb_hash? - 2KY - 12.02.2012

Does anyone have a stock for it?

pawn Код:
stock udb_hash(buf[]) { //Credits to Dracoblue
    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;
}



Re: decrypting udb_hash? - iTorran - 12.02.2012

Why do you need it?


Re: decrypting udb_hash? - Madd Kat - 12.02.2012

Why?

Ther should never be a need to decrypt a hash.
Only thing i can see is for password recovery and even that can be
Handled with out decrypting the hash


Re: decrypting udb_hash? - 2KY - 12.02.2012

pawn Код:
CMD:changepassword(playerid, params[])
{
    if(isnull(params))
        return SendClientMessage(playerid, -1, ""#LIME"<CMD USAGE> "#WHITE"/changepassword <new password>");
       
    accInfo[playerid][Passcode] = udb_hash(params);
   
    new
        INI:accFile = INI_Open(find_accPath(playerid) );
       
    INI_SetTag(accFile,     "data");
    INI_WriteInt(accFile,   "Passcode",     udb_hash(params) );
       
    INI_Close(accFile);
   
    format(pwStr, sizeof(pwStr), ""#CYAN"» "#WHITE"Your password has been changed from \"%s\" to \"%s\"", oldPass, params);
    SendClientMessage(playerid, -1, pwStr);
    return true;
}
Of course, the oldPass is why I need it.


Re: decrypting udb_hash? - iTorran - 12.02.2012

Is it a requirement to print the oldpass?


Re: decrypting udb_hash? - 2KY - 12.02.2012

No, no, I don't think you understand.

I want to send the player a message with their (decrypted) old password (i have to decrypt it, otherwise it's just a bunch of numbers), and their new password.


Re: decrypting udb_hash? - Vince - 12.02.2012

Hashes are always 1-way and cannot be decrypted. There is a difference between encrypting and encoding.


Re: decrypting udb_hash? - Madd Kat - 12.02.2012

Dont do it that way,
Require them to write old pass and new pass when changing,
Then save the non hashed old pass for display


Re: decrypting udb_hash? - 2KY - 12.02.2012

Quote:
Originally Posted by Madd Kat
Посмотреть сообщение
Dont do it that way,
Require them to write old pass and new pass when changing,
Then save the non hashed old pass for display
Alright, I will do it this way. Thanks anyways.

Quote:
Originally Posted by Vince
Посмотреть сообщение
Hashes are always 1-way and cannot be decrypted. There is a difference between encrypting and encoding.
I was not aware of this. Thanks.