StreamToHexStr

function StreamToHexStr(AStream: TStream): String;
const
  HexChars: array[0..15] of Char = '0123456789ABCDEF';
var
  i,len: Integer;
begin
  len := AStream.Size - AStream.Position;
  SetLength(Result, len * 2);
  AStream.Read(Pointer(Result)^, len);
  for i := len downto 1 do begin
    Result[i * 2]    := HexChars[Byte(Result[i]) and $0F];
    Result[i * 2 -1] := HexChars[(Byte(Result[i]) and $F0) shr 4]
  end;
end;

posted @ 2013-04-27 17:04  delphi中间件  阅读(549)  评论(0编辑  收藏  举报