-
Notifications
You must be signed in to change notification settings - Fork 4
/
CRC3_ROHC.pas
82 lines (71 loc) · 2.22 KB
/
CRC3_ROHC.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
unit CRC3_ROHC;
//CRC-3 ROHC
//Author: domasz
//Last Update: 2022-11-21
//Licence: MIT
interface
uses SysUtils, HasherBase;
type THasherCRC3_ROHC = class(THasherbase)
private
FHash: Byte;
public
constructor Create; override;
procedure Update(Msg: PByte; Length: Integer); override;
function Final: String; override;
end;
implementation
var Table: array[0..255] of Byte = (
$05, $03, $04, $02, $07, $01, $06, $00,
$01, $07, $00, $06, $03, $05, $02, $04,
$00, $06, $01, $07, $02, $04, $03, $05,
$04, $02, $05, $03, $06, $00, $07, $01,
$02, $04, $03, $05, $00, $06, $01, $07,
$06, $00, $07, $01, $04, $02, $05, $03,
$07, $01, $06, $00, $05, $03, $04, $02,
$03, $05, $02, $04, $01, $07, $00, $06,
$06, $00, $07, $01, $04, $02, $05, $03,
$02, $04, $03, $05, $00, $06, $01, $07,
$03, $05, $02, $04, $01, $07, $00, $06,
$07, $01, $06, $00, $05, $03, $04, $02,
$01, $07, $00, $06, $03, $05, $02, $04,
$05, $03, $04, $02, $07, $01, $06, $00,
$04, $02, $05, $03, $06, $00, $07, $01,
$00, $06, $01, $07, $02, $04, $03, $05,
$03, $05, $02, $04, $01, $07, $00, $06,
$07, $01, $06, $00, $05, $03, $04, $02,
$06, $00, $07, $01, $04, $02, $05, $03,
$02, $04, $03, $05, $00, $06, $01, $07,
$04, $02, $05, $03, $06, $00, $07, $01,
$00, $06, $01, $07, $02, $04, $03, $05,
$01, $07, $00, $06, $03, $05, $02, $04,
$05, $03, $04, $02, $07, $01, $06, $00,
$00, $06, $01, $07, $02, $04, $03, $05,
$04, $02, $05, $03, $06, $00, $07, $01,
$05, $03, $04, $02, $07, $01, $06, $00,
$01, $07, $00, $06, $03, $05, $02, $04,
$07, $01, $06, $00, $05, $03, $04, $02,
$03, $05, $02, $04, $01, $07, $00, $06,
$02, $04, $03, $05, $00, $06, $01, $07,
$06, $00, $07, $01, $04, $02, $05, $03
);
constructor THasherCRC3_ROHC.Create;
begin
inherited Create;
FHash := 7;
Check := '7';
end;
procedure THasherCRC3_ROHC.Update(Msg: PByte; Length: Integer);
var i: Integer;
begin
for i:=0 to Length-1 do begin
FHash := Table[($FF and (FHash xor Msg^))];
Inc(Msg);
end;
end;
function THasherCRC3_ROHC.Final: String;
begin
Result := IntToHex(FHash, 1);
end;
initialization
HasherList.RegisterHasher('CRC-3 ROHC', THasherCRC3_ROHC);
end.