-
Notifications
You must be signed in to change notification settings - Fork 4
/
CRC24_LTEB.pas
85 lines (74 loc) · 3.83 KB
/
CRC24_LTEB.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
unit CRC24_LTEB;
//CRC-24 LTE-B
//Author: domasz
//Version: 0.1 (2022-11-17)
//Licence: MIT
interface
uses SysUtils, HasherBase;
type THasherCRC24_LTEB = 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, $00800063, $008000A5, $000000C6, $00800129, $0000014A, $0000018C, $008001EF,
$00800231, $00000252, $00000294, $008002F7, $00000318, $0080037B, $008003BD, $000003DE,
$00800401, $00000462, $000004A4, $008004C7, $00000528, $0080054B, $0080058D, $000005EE,
$00000630, $00800653, $00800695, $000006F6, $00800719, $0000077A, $000007BC, $008007DF,
$00800861, $00000802, $000008C4, $008008A7, $00000948, $0080092B, $008009ED, $0000098E,
$00000A50, $00800A33, $00800AF5, $00000A96, $00800B79, $00000B1A, $00000BDC, $00800BBF,
$00000C60, $00800C03, $00800CC5, $00000CA6, $00800D49, $00000D2A, $00000DEC, $00800D8F,
$00800E51, $00000E32, $00000EF4, $00800E97, $00000F78, $00800F1B, $00800FDD, $00000FBE,
$008010A1, $000010C2, $00001004, $00801067, $00001188, $008011EB, $0080112D, $0000114E,
$00001290, $008012F3, $00801235, $00001256, $008013B9, $000013DA, $0000131C, $0080137F,
$000014A0, $008014C3, $00801405, $00001466, $00801589, $000015EA, $0000152C, $0080154F,
$00801691, $000016F2, $00001634, $00801657, $000017B8, $008017DB, $0080171D, $0000177E,
$000018C0, $008018A3, $00801865, $00001806, $008019E9, $0000198A, $0000194C, $0080192F,
$00801AF1, $00001A92, $00001A54, $00801A37, $00001BD8, $00801BBB, $00801B7D, $00001B1E,
$00801CC1, $00001CA2, $00001C64, $00801C07, $00001DE8, $00801D8B, $00801D4D, $00001D2E,
$00001EF0, $00801E93, $00801E55, $00001E36, $00801FD9, $00001FBA, $00001F7C, $00801F1F,
$00802121, $00002142, $00002184, $008021E7, $00002008, $0080206B, $008020AD, $000020CE,
$00002310, $00802373, $008023B5, $000023D6, $00802239, $0000225A, $0000229C, $008022FF,
$00002520, $00802543, $00802585, $000025E6, $00802409, $0000246A, $000024AC, $008024CF,
$00802711, $00002772, $000027B4, $008027D7, $00002638, $0080265B, $0080269D, $000026FE,
$00002940, $00802923, $008029E5, $00002986, $00802869, $0000280A, $000028CC, $008028AF,
$00802B71, $00002B12, $00002BD4, $00802BB7, $00002A58, $00802A3B, $00802AFD, $00002A9E,
$00802D41, $00002D22, $00002DE4, $00802D87, $00002C68, $00802C0B, $00802CCD, $00002CAE,
$00002F70, $00802F13, $00802FD5, $00002FB6, $00802E59, $00002E3A, $00002EFC, $00802E9F,
$00003180, $008031E3, $00803125, $00003146, $008030A9, $000030CA, $0000300C, $0080306F,
$008033B1, $000033D2, $00003314, $00803377, $00003298, $008032FB, $0080323D, $0000325E,
$00803581, $000035E2, $00003524, $00803547, $000034A8, $008034CB, $0080340D, $0000346E,
$000037B0, $008037D3, $00803715, $00003776, $00803699, $000036FA, $0000363C, $0080365F,
$008039E1, $00003982, $00003944, $00803927, $000038C8, $008038AB, $0080386D, $0000380E,
$00003BD0, $00803BB3, $00803B75, $00003B16, $00803AF9, $00003A9A, $00003A5C, $00803A3F,
$00003DE0, $00803D83, $00803D45, $00003D26, $00803CC9, $00003CAA, $00003C6C, $00803C0F,
$00803FD1, $00003FB2, $00003F74, $00803F17, $00003EF8, $00803E9B, $00803E5D, $00003E3E
);
constructor THasherCRC24_LTEB.Create;
begin
inherited Create;
FHash := $000000;
Check := '23EF52';
end;
procedure THasherCRC24_LTEB.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_LTEB.Final: String;
begin
FHash := FHash and $FFFFFF;
Result := IntToHex(FHash, 6);
end;
initialization
HasherList.RegisterHasher('CRC-24 LTE-B', THasherCRC24_LTEB);
end.