📄 funtionunit.~pas
字号:
unit FuntionUnit;
interface
var
Port: smallint;
Speed: integer;
DataBit:smallint;
Check:string;
Stop:string;
procedure CalCheck(var BA : array of byte);
procedure Ept(var BA: array of byte);
procedure AntiEpt(var BA: array of byte);
implementation
//计算校验位
procedure CalCheck(var BA : array of byte);
var
i:smallint;
mTotal:integer;
begin
//断言数据位数
Assert(Length(BA)=8,'The Length is NOT Correct!');
mTotal := $13;
for i:=0 to 6 do
begin
mTotal := mTotal + BA[i];
end;
BA[7] := mTotal mod $ff;
end;
//加密数据
procedure Ept(var BA: array of byte);
var
i:smallint;
mTmp:byte;
begin
//断言数据位数
Assert(Length(BA)=8,'The Length is NOT Correct!');
mTmp := $2a;
for i:=5 downto 1 do
begin
BA[i] := BA[i-1] xor BA[i];
end;
BA[0] := BA[5] xor $2a;
end;
procedure AntiEpt(var BA: array of byte);
var
i:smallint;
mTmp:byte;
begin
//断言数据位数
Assert(Length(BA)=8,'The Length is NOT Correct!');
BA[0] := $2a xor BA[5];
for i:=1 to 5 do
begin
BA[i] := BA[i-1] xor BA[i];
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -