【delphi开源代码栏目提醒】:网学会员,鉴于大家对delphi开源代码十分关注,论文会员在此为大家搜集整理了“FuntionUnit.pas”一文,供大家参考学习!
unit FuntionUnit;
interface
var
Port: string;
Speed: string;
DataBit:string;
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.
上一篇:
FunctionUnit.pas
下一篇:
汝康皮肤护理液医治烧伤的可行性和效果分析