3 Copyright (c) 2000 by Free Pascal Development Team
5 Routines to compute CRC values
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ****************************************************************************
26 Function Crc32(Const HStr
:String):longint;
27 Function UpdateCrc32(InitCrc
:longint;var InBuf
;InLen
:Longint):longint;
28 Function UpdCrc32(InitCrc
:longint;b
:byte):longint;
33 {*****************************************************************************
35 *****************************************************************************}
38 Crc32Tbl
: array[0..255] of longint;
40 procedure MakeCRC32Tbl
;
50 crc
:=(crc
shr 1) xor longint($edb88320)
59 {$define Range_check_on}
64 Function Crc32(Const HStr
:String):longint;
70 InitCrc
:=longint($ffffffff);
71 for i
:=1 to Length(Hstr
) do
72 InitCrc
:=Crc32Tbl
[byte(InitCrc
) xor ord(Hstr
[i
])] xor (InitCrc
shr 8);
78 Function UpdateCrc32(InitCrc
:longint;var InBuf
;InLen
:Longint):longint;
88 InitCrc
:=Crc32Tbl
[byte(InitCrc
) xor byte(p
^)] xor (InitCrc
shr 8);
96 Function UpdCrc32(InitCrc
:longint;b
:byte):longint;
100 UpdCrc32
:=Crc32Tbl
[byte(InitCrc
) xor b
] xor (InitCrc
shr 8);
103 {$ifdef Range_check_on}
105 {$undef Range_check_on}
106 {$endif Range_check_on}