The application now compiles correctly in XE2 and can decrypt records from a version compiled with Delphi 2007. Thank you all for your comments. Different points of view help to understand when variables should be defined as ANSI strings.
If someone else is trying a similar update and needs to decrypt the encryption text generated in PHP, my decryption function and the supporting padWithZeros () function come from the DCPcrypt website, so I post my modified code here. I also did not have to install the DCPcrypt update for XE2 7/21/2012, available at the following address: http://www.pepak.net/files/tools/dcpcrypt.zip .
function TForm1.AESDecrypt(const DecKeyStr: AnsiString; const DecIVStr: AnsiString; const CypherTextIn: AnsiString): String; var Cipher : TDCP_rijndael; Data, Key, IV : AnsiString; begin // Pad Key and IV with zeros as appropriate Key := PadWithZeros(DecKeyStr,KeySize); IV := PadWithZeros(DecIVStr,BlockSize); // Decode the Base64 encoded string Data := Base64DecodeStr(CypherTextIn); // Create the cipher and initialise according to the key length Cipher := TDCP_rijndael.Create(nil); if Length(DecKeyStr) <= 16 then Cipher.Init(Key[1],128,@IV[1]) else if Length(DecKeyStr) <= 24 then Cipher.Init(Key[1],192,@IV[1]) else Cipher.Init(Key[1],256,@IV[1]); // Decrypt the data Cipher.DecryptCBC(Data[1],Data[1],Length(Data)); // Free the cipher and clear sensitive information Cipher.Free; FillChar(Key[1],Length(Key),0); // Display the result Result := String(Data); (* *) end; function TForm1.PadWithZeros(const str:AnsiString; size:integer):AnsiString; var origsize, i : integer; begin Result := str; origsize := Length(Result); if ((origsize mod size) <> 0) or (origsize = 0) then begin SetLength(Result,((origsize div size)+1)*size); for i := origsize+1 to Length(Result) do Result[i] :=
source share