使用 BinToHex() 把 TBytes 转换为十六进制字符串 - 回复 "梧桐栖凤" 的问题



{函数}

function BytestoHexString(ABytes: TBytes; len: Integer): AnsiString;

begin

  SetLength(Result, len*2);

  BinToHex(@ABytes[0], PAnsiChar(Result), len);

end;



{测试}

procedure TForm1.FormCreate(Sender: TObject);

var

  bs: TBytes;

  rStr: AnsiString;

begin

  bs := BytesOf('ABCDEFG');

  rStr := BytestoHexString(bs, Length(bs));

  ShowMessage(rStr); //41424344454647

end;


你可能感兴趣的:(bytes)