function HexToStr(AHex: String): String;
var
I: Integer;
J: Byte;
R: String;
begin
J:= 0;
R:= '';
for I:=1 to (Length(AHex) div 2) do
begin
if (AHex[2 * I - 1] >= 'A') and (AHex[2 * I - 1] <= 'F') then
J:= J * 16 + (Byte(Char(AHex[2 * I - 1]))-55)
else
J:= J * 16 + StrToInt(AHex[2 * I - 1]);
if (AHex[2 * I] >= 'A') and (AHex[2 * I] <= 'F') then
J:= J * 16 + (Byte(Char(AHex[2 * I]))-55)
else
J:= J * 16 + StrToInt(AHex[2 * I]);
R:= R + Char(J);
end;
Result:= TrimRight(R);
end;