SA-MP Forums Archive
[HELP]Hasher - 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: [HELP]Hasher (/showthread.php?tid=529421)



[HELP]Hasher - nilanjay - 02.08.2014

pawn Код:
stock udb_hash(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;
}
Please, can anyone explain how the above code works?
Like why we have defined many variables, what are we returning, etc.


Re: [HELP]Hasher - GeekSiMo - 02.08.2014

In a Dialog of password, when you want to write it with dini or Y_INI, You udb_hash(inputtext).


Re: [HELP]Hasher - nilanjay - 02.08.2014

Quote:
Originally Posted by GeekSiMo
Посмотреть сообщение
In a Dialog of password, when you want to write it with dini or Y_INI, You udb_hash(inputtext).
Thanks for the reply, I know why this code is used but I want to know the meaning of the lines in the code like what is happening in

pawn Код:
for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;



Re: [HELP]Hasher - GeekSiMo - 02.08.2014

Ask DracoBlue