## checksum

This forum contains all information about TDBAccess library for NHL 2004 roster access and general NHL coding questions.

Moderator: Owen

guest

### checksum

HI !

How did you calculate the checksum (crc) of a tdb file?

Thanx!

vincent_filion@yahoo.com

Artem
Posts: 1166
Joined: Thu Oct 23, 2003 5:30 pm
What do you mean? How I got "the formula" or you want "the formula" itself?

guest

### checksum

HI !

I know theres a checksum for each table in the tdb file but how did you calcul it..

Yes I want the formula.. please :)

Vince.

vincent_filion@yahoo.com

Artem
Posts: 1166
Joined: Thu Oct 23, 2003 5:30 pm
Here is Pascal version. I just directly converted it from assembler so there is probably a way to make it more compact, I didn't bother.

Code: Select all

``````var HashTable: array[0..255] of LongWord;

function HashBuffer(Buffer: PChar; BufSize: LongWord; InitHash: LongWord): LongWord;

procedure CreateHashTable;
var
ax, si, cx: Longword;
i: byte;
begin
cx := 0;
for i := Low(HashTable) to High(HashTable) do
begin
ax := cx;
ax := ax shl \$18;
for si := 0 to 7 do
begin
if (integer(ax) >= 0) then
begin
ax := ax shl 1;
end
else
begin
ax := ax + ax;
ax := ax xor \$4C11DB7;
end;
end;
HashTable[i] := ax;
Inc(cx);
end;
end;

var
ax, si: LongWord;
di: byte;
i: LongWord;
begin
if (integer(HashTable) >= 0) then
begin
CreateHashTable;
ax := InitHash;
end
else
ax := InitHash;
for i := 0 to BufSize - 1 do
begin
di := Byte(Buffer[i]);
si := ax;
si := si shr \$18;
si := si xor di;
si := HashTable[si];
ax := ax shl 8;
ax := ax xor si;
end;
Result := ax;
end;
``````
When calling HashBuffer, Buffer is pointer to the section of TDB file you want to hash and InitHash is \$FFFFFFFF. 