0

Iam migrating an app from Delphi 7 to Delphi XE5, the below is my function.

function InternalDecrypt(const S: AnsiString; Key: Word): AnsiString;
var
  I: Word;
  Seed: Word;
begin
  Result := S;
  Seed := Key;
  for I := 1 to Length(Result) do
  begin
    Result[I] := Char(Byte(Result[I]) xor (Seed shr 8)); //Error is here
    Seed := (Byte(S[I]) + Seed) * Word(C1) + Word(C2)
  end
end;

My Error is : incompatible types 'ansichar' and 'char' delphi, Can any one just guide me in the right way.

userhi
  • 553
  • 1
  • 7
  • 27
  • Have you done any research at all? Surely you must appreciate that `Char` changes from `AnsiChar` to `WideChar` from Delphi 2009. You need to step back and read around that change. Carefully. And you really must stop treating text as though it is binary data. It really is not. – David Heffernan Dec 10 '16 at 13:15

1 Answers1

1

Try

Result[I] := AnsiChar(Byte(Result[I]) xor (Seed shr 8));

with c1 and c2 as ansichar type.