I have the following code :
user_s.username := EnDecrypt(Edit_username.Text);
The function is the following :
function EnDeCrypt(const Value : String) : String;
var
CharIndex : integer;
begin
Result := Value;
for CharIndex := 1 to Length(Value) do
Result[CharIndex] := chr(not(ord(Value[CharIndex])));
end;
the type of variable is :
TUser = record
access: char;
username: string[25];
password: string[25];
end;
In Delphi 2007 it works, in Delphi XE2 it fails. The curious thing is that it encrypts/decrypts well the password if it is 123456789. The issue must be related with unicode and the use of shortstring. I hope there is some way to make it work in Delphi XE2 as well..
Replace
Stringtype withAnsiString, andCharwithAnsiChar, and the code will work exactly as in Delphi 2007. (String[25]should not be altered, though.) Of course, you will not get Unicode support.