-
Notifications
You must be signed in to change notification settings - Fork 3
/
CRC32_CDROMEDC.pas
84 lines (71 loc) · 3.79 KB
/
CRC32_CDROMEDC.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
unit CRC32_CDROMEDC;
//CRC-32 CD-ROM-EDC
//Author: domasz
//Last Update: 2022-11-20
//Licence: MIT
interface
uses SysUtils, HasherBase;
type THasherCRC32_CDROMEDC= class(THasherbase)
private
FHash: Cardinal;
public
constructor Create; override;
procedure Update(Msg: PByte; Length: Integer); override;
function Final: String; override;
end;
implementation
var Table: array[0..255] of LongInt = (
$00000000, $90910101, $91210201, $01B00300, $92410401, $02D00500, $03600600, $93F10701,
$94810801, $04100900, $05A00A00, $95310B01, $06C00C00, $96510D01, $97E10E01, $07700F00,
$99011001, $09901100, $08201200, $98B11301, $0B401400, $9BD11501, $9A611601, $0AF01700,
$0D801800, $9D111901, $9CA11A01, $0C301B00, $9FC11C01, $0F501D00, $0EE01E00, $9E711F01,
$82012001, $12902100, $13202200, $83B12301, $10402400, $80D12501, $81612601, $11F02700,
$16802800, $86112901, $87A12A01, $17302B00, $84C12C01, $14502D00, $15E02E00, $85712F01,
$1B003000, $8B913101, $8A213201, $1AB03300, $89413401, $19D03500, $18603600, $88F13701,
$8F813801, $1F103900, $1EA03A00, $8E313B01, $1DC03C00, $8D513D01, $8CE13E01, $1C703F00,
$B4014001, $24904100, $25204200, $B5B14301, $26404400, $B6D14501, $B7614601, $27F04700,
$20804800, $B0114901, $B1A14A01, $21304B00, $B2C14C01, $22504D00, $23E04E00, $B3714F01,
$2D005000, $BD915101, $BC215201, $2CB05300, $BF415401, $2FD05500, $2E605600, $BEF15701,
$B9815801, $29105900, $28A05A00, $B8315B01, $2BC05C00, $BB515D01, $BAE15E01, $2A705F00,
$36006000, $A6916101, $A7216201, $37B06300, $A4416401, $34D06500, $35606600, $A5F16701,
$A2816801, $32106900, $33A06A00, $A3316B01, $30C06C00, $A0516D01, $A1E16E01, $31706F00,
$AF017001, $3F907100, $3E207200, $AEB17301, $3D407400, $ADD17501, $AC617601, $3CF07700,
$3B807800, $AB117901, $AAA17A01, $3A307B00, $A9C17C01, $39507D00, $38E07E00, $A8717F01,
$D8018001, $48908100, $49208200, $D9B18301, $4A408400, $DAD18501, $DB618601, $4BF08700,
$4C808800, $DC118901, $DDA18A01, $4D308B00, $DEC18C01, $4E508D00, $4FE08E00, $DF718F01,
$41009000, $D1919101, $D0219201, $40B09300, $D3419401, $43D09500, $42609600, $D2F19701,
$D5819801, $45109900, $44A09A00, $D4319B01, $47C09C00, $D7519D01, $D6E19E01, $46709F00,
$5A00A000, $CA91A101, $CB21A201, $5BB0A300, $C841A401, $58D0A500, $5960A600, $C9F1A701,
$CE81A801, $5E10A900, $5FA0AA00, $CF31AB01, $5CC0AC00, $CC51AD01, $CDE1AE01, $5D70AF00,
$C301B001, $5390B100, $5220B200, $C2B1B301, $5140B400, $C1D1B501, $C061B601, $50F0B700,
$5780B800, $C711B901, $C6A1BA01, $5630BB00, $C5C1BC01, $5550BD00, $54E0BE00, $C471BF01,
$6C00C000, $FC91C101, $FD21C201, $6DB0C300, $FE41C401, $6ED0C500, $6F60C600, $FFF1C701,
$F881C801, $6810C900, $69A0CA00, $F931CB01, $6AC0CC00, $FA51CD01, $FBE1CE01, $6B70CF00,
$F501D001, $6590D100, $6420D200, $F4B1D301, $6740D400, $F7D1D501, $F661D601, $66F0D700,
$6180D800, $F111D901, $F0A1DA01, $6030DB00, $F3C1DC01, $6350DD00, $62E0DE00, $F271DF01,
$EE01E001, $7E90E100, $7F20E200, $EFB1E301, $7C40E400, $ECD1E501, $ED61E601, $7DF0E700,
$7A80E800, $EA11E901, $EBA1EA01, $7B30EB00, $E8C1EC01, $7850ED00, $79E0EE00, $E971EF01,
$7700F000, $E791F101, $E621F201, $76B0F300, $E541F401, $75D0F500, $7460F600, $E4F1F701,
$E381F801, $7310F900, $72A0FA00, $E231FB01, $71C0FC00, $E151FD01, $E0E1FE01, $7070FF00
);
constructor THasherCRC32_CDROMEDC.Create;
begin
inherited Create;
FHash := $00000000;
Check := '6EC2EDC4';
end;
procedure THasherCRC32_CDROMEDC.Update(Msg: PByte; Length: Integer);
var i: Integer;
begin
for i:=0 to Length-1 do begin
FHash := (FHash shr 8) xor Table[byte(FHash) xor Msg^];
Inc(Msg);
end;
end;
function THasherCRC32_CDROMEDC.Final: String;
begin
Result := IntToHex(FHash, 8);
end;
initialization
HasherList.RegisterHasher('CRC-32 CD-ROM-EDC', THasherCRC32_CDROMEDC);
end.