1、从delphi转lazarus for linux,如果原来代码用CopyMemory和ZeroMemory编译时会出错。移植代码时可以用move替换CopyMemory,FillChar替换ZeroMemory,最简单的方法是自己按以下方法写CopyMemory和ZeroMemory。
{$ifdef linux}
procedure CopyMemory(Destination, Source:pointer; Length:DWORD);
begin
Move(Source^, Destination^, Length);
end;
procedure ZeroMemory(Destination:pointer; Length:DWORD);
begin
FillChar(Destination^,Length,#0);
end;
{$endif}
2、TEncoding.Default.GetBytes(IvStr);返回的不是正确的,用StrToBytes替换TEncoding.Default.GetBytes就可以。
function StrToBytes(const S: AnsiString): TBytes; begin if S <> '' then begin SetLength(Result, Length(S)); Move(S[1], Result[0], Length(S)); end else Result := nil; end; function BytesToStr(Data: TBytes): AnsiString; begin if Length(Data) > 0 then begin SetLength(Result, Length(Data)); Move(Data[0], Result[1], Length(Data)); end else Result := ''; end;
IvBytes := TEncoding.Default.GetBytes(IvStr);
改为:
IvBytes := StrToBytes(IvStr);

浙公网安备 33010602011771号