1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| function ToStrByte(ansi: AnsiString): TBytes; begin SetLength(Result, Length(ansi)); Move(ansi[1], Result[0], Length(ansi)); end;
function ToByteStr(b: TBytes): AnsiString; begin SetLength(Result, Length(b)); Move(b[0], Result[1], Length(b)); end;
function ToByteHex(b: TBytes): AnsiString; var i: integer; begin Result := ''; for i in b do Result := Result + IntToHex(i, 2); end;
function ToHexByte(hex: AnsiString): TBytes; var i: Integer; begin SetLength(Result, Length(hex) div 2); for i:= 0 to Length(Result) - 1 do Result[i] := StrToInt('$' + Copy(hex, (i*2) + 1, 2)); end;
|