-
Notifications
You must be signed in to change notification settings - Fork 3
/
CRC32_MEF.pas
84 lines (71 loc) · 3.74 KB
/
CRC32_MEF.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_MEF;
//CRC-32 MEF
//Author: domasz
//Last Update: 2022-11-20
//Licence: MIT
interface
uses SysUtils, HasherBase;
type THasherCRC32_MEF= 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, $9695C4CA, $FB4839C9, $6DDDFD03, $20F3C3CF, $B6660705, $DBBBFA06, $4D2E3ECC,
$41E7879E, $D7724354, $BAAFBE57, $2C3A7A9D, $61144451, $F781809B, $9A5C7D98, $0CC9B952,
$83CF0F3C, $155ACBF6, $788736F5, $EE12F23F, $A33CCCF3, $35A90839, $5874F53A, $CEE131F0,
$C22888A2, $54BD4C68, $3960B16B, $AFF575A1, $E2DB4B6D, $744E8FA7, $199372A4, $8F06B66E,
$D1FDAE25, $47686AEF, $2AB597EC, $BC205326, $F10E6DEA, $679BA920, $0A465423, $9CD390E9,
$901A29BB, $068FED71, $6B521072, $FDC7D4B8, $B0E9EA74, $267C2EBE, $4BA1D3BD, $DD341777,
$5232A119, $C4A765D3, $A97A98D0, $3FEF5C1A, $72C162D6, $E454A61C, $89895B1F, $1F1C9FD5,
$13D52687, $8540E24D, $E89D1F4E, $7E08DB84, $3326E548, $A5B32182, $C86EDC81, $5EFB184B,
$7598EC17, $E30D28DD, $8ED0D5DE, $18451114, $556B2FD8, $C3FEEB12, $AE231611, $38B6D2DB,
$347F6B89, $A2EAAF43, $CF375240, $59A2968A, $148CA846, $82196C8C, $EFC4918F, $79515545,
$F657E32B, $60C227E1, $0D1FDAE2, $9B8A1E28, $D6A420E4, $4031E42E, $2DEC192D, $BB79DDE7,
$B7B064B5, $2125A07F, $4CF85D7C, $DA6D99B6, $9743A77A, $01D663B0, $6C0B9EB3, $FA9E5A79,
$A4654232, $32F086F8, $5F2D7BFB, $C9B8BF31, $849681FD, $12034537, $7FDEB834, $E94B7CFE,
$E582C5AC, $73170166, $1ECAFC65, $885F38AF, $C5710663, $53E4C2A9, $3E393FAA, $A8ACFB60,
$27AA4D0E, $B13F89C4, $DCE274C7, $4A77B00D, $07598EC1, $91CC4A0B, $FC11B708, $6A8473C2,
$664DCA90, $F0D80E5A, $9D05F359, $0B903793, $46BE095F, $D02BCD95, $BDF63096, $2B63F45C,
$EB31D82E, $7DA41CE4, $1079E1E7, $86EC252D, $CBC21BE1, $5D57DF2B, $308A2228, $A61FE6E2,
$AAD65FB0, $3C439B7A, $519E6679, $C70BA2B3, $8A259C7F, $1CB058B5, $716DA5B6, $E7F8617C,
$68FED712, $FE6B13D8, $93B6EEDB, $05232A11, $480D14DD, $DE98D017, $B3452D14, $25D0E9DE,
$2919508C, $BF8C9446, $D2516945, $44C4AD8F, $09EA9343, $9F7F5789, $F2A2AA8A, $64376E40,
$3ACC760B, $AC59B2C1, $C1844FC2, $57118B08, $1A3FB5C4, $8CAA710E, $E1778C0D, $77E248C7,
$7B2BF195, $EDBE355F, $8063C85C, $16F60C96, $5BD8325A, $CD4DF690, $A0900B93, $3605CF59,
$B9037937, $2F96BDFD, $424B40FE, $D4DE8434, $99F0BAF8, $0F657E32, $62B88331, $F42D47FB,
$F8E4FEA9, $6E713A63, $03ACC760, $953903AA, $D8173D66, $4E82F9AC, $235F04AF, $B5CAC065,
$9EA93439, $083CF0F3, $65E10DF0, $F374C93A, $BE5AF7F6, $28CF333C, $4512CE3F, $D3870AF5,
$DF4EB3A7, $49DB776D, $24068A6E, $B2934EA4, $FFBD7068, $6928B4A2, $04F549A1, $92608D6B,
$1D663B05, $8BF3FFCF, $E62E02CC, $70BBC606, $3D95F8CA, $AB003C00, $C6DDC103, $504805C9,
$5C81BC9B, $CA147851, $A7C98552, $315C4198, $7C727F54, $EAE7BB9E, $873A469D, $11AF8257,
$4F549A1C, $D9C15ED6, $B41CA3D5, $2289671F, $6FA759D3, $F9329D19, $94EF601A, $027AA4D0,
$0EB31D82, $9826D948, $F5FB244B, $636EE081, $2E40DE4D, $B8D51A87, $D508E784, $439D234E,
$CC9B9520, $5A0E51EA, $37D3ACE9, $A1466823, $EC6856EF, $7AFD9225, $17206F26, $81B5ABEC,
$8D7C12BE, $1BE9D674, $76342B77, $E0A1EFBD, $AD8FD171, $3B1A15BB, $56C7E8B8, $C0522C72
);
constructor THasherCRC32_MEF.Create;
begin
inherited Create;
FHash := $FFFFFFFF;
Check := 'D2C22F51';
end;
procedure THasherCRC32_MEF.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_MEF.Final: String;
begin
Result := IntToHex(FHash, 8);
end;
initialization
HasherList.RegisterHasher('CRC-32 MEF', THasherCRC32_MEF);
end.