-
Notifications
You must be signed in to change notification settings - Fork 3
/
CRC24_INTERLAKEN.pas
86 lines (75 loc) · 3.91 KB
/
CRC24_INTERLAKEN.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
85
86
unit CRC24_INTERLAKEN;
//CRC-24 INTERLAKEN
//Author: domasz
//Version: 0.1 (2022-11-17)
//Licence: MIT
interface
uses SysUtils, HasherBase;
type THasherCRC24_INTERLAKEN = 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, $00328B63, $006516C6, $00579DA5, $00CA2D8C, $00F8A6EF, $00AF3B4A, $009DB029,
$00A6D07B, $00945B18, $00C3C6BD, $00F14DDE, $006CFDF7, $005E7694, $0009EB31, $003B6052,
$007F2B95, $004DA0F6, $001A3D53, $0028B630, $00B50619, $00878D7A, $00D010DF, $00E29BBC,
$00D9FBEE, $00EB708D, $00BCED28, $008E664B, $0013D662, $00215D01, $0076C0A4, $00444BC7,
$00FE572A, $00CCDC49, $009B41EC, $00A9CA8F, $00347AA6, $0006F1C5, $00516C60, $0063E703,
$00588751, $006A0C32, $003D9197, $000F1AF4, $0092AADD, $00A021BE, $00F7BC1B, $00C53778,
$00817CBF, $00B3F7DC, $00E46A79, $00D6E11A, $004B5133, $0079DA50, $002E47F5, $001CCC96,
$0027ACC4, $001527A7, $0042BA02, $00703161, $00ED8148, $00DF0A2B, $0088978E, $00BA1CED,
$00CE2537, $00FCAE54, $00AB33F1, $0099B892, $000408BB, $003683D8, $00611E7D, $0053951E,
$0068F54C, $005A7E2F, $000DE38A, $003F68E9, $00A2D8C0, $009053A3, $00C7CE06, $00F54565,
$00B10EA2, $008385C1, $00D41864, $00E69307, $007B232E, $0049A84D, $001E35E8, $002CBE8B,
$0017DED9, $002555BA, $0072C81F, $0040437C, $00DDF355, $00EF7836, $00B8E593, $008A6EF0,
$0030721D, $0002F97E, $005564DB, $0067EFB8, $00FA5F91, $00C8D4F2, $009F4957, $00ADC234,
$0096A266, $00A42905, $00F3B4A0, $00C13FC3, $005C8FEA, $006E0489, $0039992C, $000B124F,
$004F5988, $007DD2EB, $002A4F4E, $0018C42D, $00857404, $00B7FF67, $00E062C2, $00D2E9A1,
$00E989F3, $00DB0290, $008C9F35, $00BE1456, $0023A47F, $00112F1C, $0046B2B9, $007439DA,
$00AEC10D, $009C4A6E, $00CBD7CB, $00F95CA8, $0064EC81, $005667E2, $0001FA47, $00337124,
$00081176, $003A9A15, $006D07B0, $005F8CD3, $00C23CFA, $00F0B799, $00A72A3C, $0095A15F,
$00D1EA98, $00E361FB, $00B4FC5E, $0086773D, $001BC714, $00294C77, $007ED1D2, $004C5AB1,
$00773AE3, $0045B180, $00122C25, $0020A746, $00BD176F, $008F9C0C, $00D801A9, $00EA8ACA,
$00509627, $00621D44, $003580E1, $00070B82, $009ABBAB, $00A830C8, $00FFAD6D, $00CD260E,
$00F6465C, $00C4CD3F, $0093509A, $00A1DBF9, $003C6BD0, $000EE0B3, $00597D16, $006BF675,
$002FBDB2, $001D36D1, $004AAB74, $00782017, $00E5903E, $00D71B5D, $008086F8, $00B20D9B,
$00896DC9, $00BBE6AA, $00EC7B0F, $00DEF06C, $00434045, $0071CB26, $00265683, $0014DDE0,
$0060E43A, $00526F59, $0005F2FC, $0037799F, $00AAC9B6, $009842D5, $00CFDF70, $00FD5413,
$00C63441, $00F4BF22, $00A32287, $0091A9E4, $000C19CD, $003E92AE, $00690F0B, $005B8468,
$001FCFAF, $002D44CC, $007AD969, $0048520A, $00D5E223, $00E76940, $00B0F4E5, $00827F86,
$00B91FD4, $008B94B7, $00DC0912, $00EE8271, $00733258, $0041B93B, $0016249E, $0024AFFD,
$009EB310, $00AC3873, $00FBA5D6, $00C92EB5, $00549E9C, $006615FF, $0031885A, $00030339,
$0038636B, $000AE808, $005D75AD, $006FFECE, $00F24EE7, $00C0C584, $00975821, $00A5D342,
$00E19885, $00D313E6, $00848E43, $00B60520, $002BB509, $00193E6A, $004EA3CF, $007C28AC,
$004748FE, $0075C39D, $00225E38, $0010D55B, $008D6572, $00BFEE11, $00E873B4, $00DAF8D7
);
constructor THasherCRC24_INTERLAKEN.Create;
begin
inherited Create;
FHash := $FFFFFF;
Check := 'B4F3E6';
end;
procedure THasherCRC24_INTERLAKEN.Update(Msg: PByte; Length: Integer);
var i: Integer;
Index: Cardinal;
begin
for i:=0 to Length-1 do begin
Index := (Msg^ xor (FHash shr 16)) and $FF;
FHash := (FHash shl 8) xor Table[index];
Inc(Msg);
end;
end;
function THasherCRC24_INTERLAKEN.Final: String;
begin
FHash := FHash and $FFFFFF;
FHash := FHash xor $FFFFFF;
Result := IntToHex(FHash, 6);
end;
initialization
HasherList.RegisterHasher('CRC-24 INTERLAKEN', THasherCRC24_INTERLAKEN);
end.