HexChars : Array[0..15] of Char = '0123456789ABCDEF';
var
i, j: WORD;
begin
SetLength(hHexStr, (InputLength*2));
FillChar(hHexStr, sizeof(hHexStr),#0);
j := 1;
for i := 1 to InputLength do begin
hHexStr[j] := Char(HexChars[pbyteArray^ shr 4]); inc(j);
hHexStr[j] := Char(HexChars[pbyteArray^ and 15]); inc(j);
inc(pbyteArray);
end;
end;
procedure HexBytesToChar(var Response: String; hexbytes:PChar; InputLength: WORD);
var
i: WORD;
c: byte;
begin
SetLength(Response, InputLength);
FillChar(Response, SizeOf(Response),#0);
for i := 0 to (InputLength - 1) do begin
c := BYTE(hexbytes[i]) And BYTE($f);
if c > 9 then Inc(c, $37)
else Inc(c, $30);
Response[i + 1]:= char(c);
end;{for}
end;
procedure HexStrToBytes(hHexStr: String; pbyteArray: Pointer);
{pbyteArray указывает на область памяти, хранящей результаты}
var
i, j: WORD;
tempPtr: PChar;
twoDigits : String[2];
begin
tempPtr := pbyteArray;
j := 1;
for i := 1 to (Length(hHexStr) DIV 2) do begin
twoDigits := Copy(hHexStr,j, 2); Inc(j, 2);
PByte(tempPtr)^ := StrToInt('$' + twoDigits); Inc(tempPtr);
end;{for}
end;
end.