function BinToHexStr(Buf: Pointer; Len: Integer): string;
const
HexString: array[0..15] of Char = '0123456789ABCDEF';
var
i: Integer;
P: PByte;
begin
P := Buf;
i := 1;
SetLength(Result, Len * 3);
while i < Length(Result) do
begin
Result[i] := HexString[P^ shr 4];
Result[i + 1] := HexString[P^ and $F];
Result[i + 2] := ' ';
Inc(P);
Inc(i, 3);
end;
end;