Function bkdrhash (BUF: pointer; count: integer): Cardinal; assembler; <br/> ASM <br/> push EBX; <br/> xor ebx, EBX <br/> mov ECx, eax <br/> XOR eax, eax <br/> @ loop: <br/> test edX, edX <br/> JZ @ exit <br/> mov BL, [ECx] <br/> imul eax, 131 <br/> Add eax, EBX <br/> Inc ECx <br/> dec edX <br/> JMP @ loop <br/> @ Exit: <br/> pop EBX <br/> // -------------------------- <br/> // Pascal: <br/> // result: = 0; <br/> // while count> 0 DO <br/> // begin <br/> // result: = (result * 131) + pbyte (BUF) ^; <br/> // Inc (pbpbyte (BUF); <br/> // Dec (count); <br/> // end; <br/> end; <br/> function djbhash (BUF: pointer; count: integer): Cardinal; Cycler; <br/> ASM <br/> push EDI <br/> push EBX <br/> xor ebx, EBX <br/> mov ECx, eax <br/> mov eax, 5381 <br/> @ loop: <br/> test edX, EDX <br/> JZ @ exit <br/> mov EDI, eax <br/> shl edi, 5 <br/> Add eax, EDI <br/> mov BL, [ECx] <br/> Add eax, EBX <br/> Inc ECx <br/> dec edX <br/> JMP @ loop <br/> @ Exit: <br/> pop EBX <br/> pop EDI <br/> // -------------------------- <br/> // Pascal: <br/> // result: = 5381; <br/> // while count> 0 DO <br/> // begin <br/> // result: = (result SHL 5) + result) + pbyte (BUF) ^; <br/> // Inc (pbyte (BUF); <br/> // Dec (count); <br/>/end; <br/> end;
Various Hash FunctionsAlgorithmSee:
Http://www.partow.net/programming/hashfunctions/