Help please. Please point me to code to perform a 32 bit or 64 bit hash. Thanks much.
Posted on 2005-02-05 17:58:09 by V Coder
Hello,

The only 32bit hash I can think of is crc. I cannot think of any 64bit hash.
Posted on 2005-02-05 19:18:18 by roticv
Hi,
If you're looking for CRC32, here's some code I wrote a couple 100 years ago. Very ugly code tho, it was actually meant to be ugly, but at least you'll get an idea :)

; allocate 1024 bytes for CRC table first and put a pointer to it in pCRCTable


; GenerateTable is ripped from VC++ generated asm
GenerateTable PROC
pushad
mov edi, pCRCTable
xor ecx, ecx
$L42269:
mov eax, ecx
mov edx, 8
$L42273:
test al, 1
je short $L42276
shr eax, 1
xor eax, 0EDB88320h
jmp short $L42274
$L42276:
shr eax, 1
$L42274:
dec edx
jne short $L42273
stosd
inc ecx
cmp ecx, 256
jl short $L42269
popad
ret
GenerateTable ENDP

;//////////////////////////////////////////////////////////////////////

; filename in ebx
CRC32 PROC

invoke _lopen, ebx, OF_READ
mov edi, eax

mov edx, -1

@CRCLoop:
lea esi, [esp-5000]
push edx
invoke _lread, edi, esi, 4096
pop edx
mov ecx, eax
test eax, eax
jz @CRCDone

@CRCLoop2:
lodsb
mov ebx, edx
xor ebx, eax
and ebx, 255

mov eax, pCRCTable
mov eax, dword ptr [eax+4*ebx]

shr edx, 8
xor edx, eax

loop short @CRCLoop2

jmp short @CRCLoop

@CRCDone:

mov eax, edx
not eax

ret
CRC32 ENDP
Posted on 2005-02-10 09:35:58 by snq