-
Notifications
You must be signed in to change notification settings - Fork 3
/
CRC32_AIXM.pas
84 lines (71 loc) · 3.75 KB
/
CRC32_AIXM.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_AIXM;
//CRC-32 AIXM
//Author: domasz
//Last Update: 2022-11-20
//Licence: MIT
interface
uses SysUtils, HasherBase;
type THasherCRC32_AIXM = 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, $814141AB, $83C3C2FD, $02828356, $86C6C451, $078785FA, $050506AC, $84444707,
$8CCCC909, $0D8D88A2, $0F0F0BF4, $8E4E4A5F, $0A0A0D58, $8B4B4CF3, $89C9CFA5, $08888E0E,
$98D8D3B9, $19999212, $1B1B1144, $9A5A50EF, $1E1E17E8, $9F5F5643, $9DDDD515, $1C9C94BE,
$14141AB0, $95555B1B, $97D7D84D, $169699E6, $92D2DEE1, $13939F4A, $11111C1C, $90505DB7,
$B0F0E6D9, $31B1A772, $33332424, $B272658F, $36362288, $B7776323, $B5F5E075, $34B4A1DE,
$3C3C2FD0, $BD7D6E7B, $BFFFED2D, $3EBEAC86, $BAFAEB81, $3BBBAA2A, $3939297C, $B87868D7,
$28283560, $A96974CB, $ABEBF79D, $2AAAB636, $AEEEF131, $2FAFB09A, $2D2D33CC, $AC6C7267,
$A4E4FC69, $25A5BDC2, $27273E94, $A6667F3F, $22223838, $A3637993, $A1E1FAC5, $20A0BB6E,
$E0A08C19, $61E1CDB2, $63634EE4, $E2220F4F, $66664848, $E72709E3, $E5A58AB5, $64E4CB1E,
$6C6C4510, $ED2D04BB, $EFAF87ED, $6EEEC646, $EAAA8141, $6BEBC0EA, $696943BC, $E8280217,
$78785FA0, $F9391E0B, $FBBB9D5D, $7AFADCF6, $FEBE9BF1, $7FFFDA5A, $7D7D590C, $FC3C18A7,
$F4B496A9, $75F5D702, $77775454, $F63615FF, $727252F8, $F3331353, $F1B19005, $70F0D1AE,
$50506AC0, $D1112B6B, $D393A83D, $52D2E996, $D696AE91, $57D7EF3A, $55556C6C, $D4142DC7,
$DC9CA3C9, $5DDDE262, $5F5F6134, $DE1E209F, $5A5A6798, $DB1B2633, $D999A565, $58D8E4CE,
$C888B979, $49C9F8D2, $4B4B7B84, $CA0A3A2F, $4E4E7D28, $CF0F3C83, $CD8DBFD5, $4CCCFE7E,
$44447070, $C50531DB, $C787B28D, $46C6F326, $C282B421, $43C3F58A, $414176DC, $C0003777,
$40005999, $C1411832, $C3C39B64, $4282DACF, $C6C69DC8, $4787DC63, $45055F35, $C4441E9E,
$CCCC9090, $4D8DD13B, $4F0F526D, $CE4E13C6, $4A0A54C1, $CB4B156A, $C9C9963C, $4888D797,
$D8D88A20, $5999CB8B, $5B1B48DD, $DA5A0976, $5E1E4E71, $DF5F0FDA, $DDDD8C8C, $5C9CCD27,
$54144329, $D5550282, $D7D781D4, $5696C07F, $D2D28778, $5393C6D3, $51114585, $D050042E,
$F0F0BF40, $71B1FEEB, $73337DBD, $F2723C16, $76367B11, $F7773ABA, $F5F5B9EC, $74B4F847,
$7C3C7649, $FD7D37E2, $FFFFB4B4, $7EBEF51F, $FAFAB218, $7BBBF3B3, $793970E5, $F878314E,
$68286CF9, $E9692D52, $EBEBAE04, $6AAAEFAF, $EEEEA8A8, $6FAFE903, $6D2D6A55, $EC6C2BFE,
$E4E4A5F0, $65A5E45B, $6727670D, $E66626A6, $622261A1, $E363200A, $E1E1A35C, $60A0E2F7,
$A0A0D580, $21E1942B, $2363177D, $A22256D6, $266611D1, $A727507A, $A5A5D32C, $24E49287,
$2C6C1C89, $AD2D5D22, $AFAFDE74, $2EEE9FDF, $AAAAD8D8, $2BEB9973, $29691A25, $A8285B8E,
$38780639, $B9394792, $BBBBC4C4, $3AFA856F, $BEBEC268, $3FFF83C3, $3D7D0095, $BC3C413E,
$B4B4CF30, $35F58E9B, $37770DCD, $B6364C66, $32720B61, $B3334ACA, $B1B1C99C, $30F08837,
$10503359, $911172F2, $9393F1A4, $12D2B00F, $9696F708, $17D7B6A3, $155535F5, $9414745E,
$9C9CFA50, $1DDDBBFB, $1F5F38AD, $9E1E7906, $1A5A3E01, $9B1B7FAA, $9999FCFC, $18D8BD57,
$8888E0E0, $09C9A14B, $0B4B221D, $8A0A63B6, $0E4E24B1, $8F0F651A, $8D8DE64C, $0CCCA7E7,
$044429E9, $85056842, $8787EB14, $06C6AABF, $8282EDB8, $03C3AC13, $01412F45, $80006EEE
);
constructor THasherCRC32_AIXM.Create;
begin
inherited Create;
FHash := $00000000;
Check := '3010BF7F';
end;
procedure THasherCRC32_AIXM.Update(Msg: PByte; Length: Integer);
var i: Integer;
begin
for i:=0 to Length-1 do begin
FHash := (FHash shl 8) xor Table[Msg^ xor (FHash shr 24)];
Inc(Msg);
end;
end;
function THasherCRC32_AIXM.Final: String;
begin
Result := IntToHex(FHash, 8);
end;
initialization
HasherList.RegisterHasher('CRC-32 AIXM', THasherCRC32_AIXM);
end.