Advertisement
0xNOP

Convert Data Buff to Ascii / Hex

Jun 13th, 2016
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.83 KB | None | 0 0
  1. function ConvertDataToAscii(Buffer: Pointer; Length: Word): string;
  2.   var
  3.     Iterator: Integer;
  4.     AsciiBuffer: string;
  5.   begin
  6.     AsciiBuffer := '';
  7.     for Iterator := 0 to Length - 1 do
  8.     begin
  9.       if char(Pointer(Integer(Buffer) + Iterator)^) in [#32 .. #127] then
  10.         AsciiBuffer := AsciiBuffer + ' ' +
  11.           char(Pointer(Integer(Buffer) + Iterator)^) + ' '
  12.       else
  13.         AsciiBuffer := AsciiBuffer + ' . ';
  14.     end;
  15.     Result := AsciiBuffer;
  16.   end;
  17.  
  18.   function ConvertDataToHex(Buffer: Pointer; Length: Word): string;
  19.   var
  20.     Iterator: Integer;
  21.     HexBuffer: string;
  22.   begin
  23.     HexBuffer := '';
  24.     for Iterator := 0 to Length - 1 do
  25.     begin
  26.       HexBuffer := HexBuffer +
  27.         IntToHex(Ord(char(Pointer(Integer(Buffer) + Iterator)^)), 2) + ' ';
  28.     end;
  29.     Result := HexBuffer;
  30.   end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement