Invalid Operation: -207

I send you an example code wich has - when build with the current version 5.X - problems decrypting.
References to old are build with 4.3.3, references to new are build with 5.0.X

Thanks, I have replied today.

Solved with an updated class.
Will it be inculded in future release?

Once you have used the patch, you should no longer need it and use the class as it is.

Have the same Problem with the newest Version of TMSEncryptedIniFile. old Ini-Files are no longer readable. Old Outputformat was Base64. How to read these Files with the new Version?
This is a showstoper for me. C'ant update to Delphi 13 with this Version of TMSCryptopack. Please elaborate!

What version are you using? 5.0.9.9?

yes

Any news on this?

Please... any news??? i am clients stoped :-(

In Create(const FileName, Key: string), comment LoadValues to recover the initial file with new parameters.
Then remove the comments and recompile.

:face_with_monocle: are you serious?

Can you add and use these?

constructor TEncryptedIniFile.Create(const FileName, Key: string;
  const Uni: TUnicode; const OutputFormat: TConvertType);
begin
  FUni := Uni;
  FKey := Key;
  FFileName     := FileName;
  FInputFormat  := OutputFormat;
  FOutputFormat := OutputFormat;
  inherited Create(FileName);
  LoadValues1;
end;

then:


procedure TEncryptedIniFile.LoadValues1;
var
  List: TStringList;
  Stream: TFileStream;
  ss: TStringList;
  aes: TAESEncryption;
conv: TConvert;

begin
  try
    if (FFileName <> '') and FileExists(FFileName) then begin
      Stream := TFileStream.Create(FFileName, fmOpenRead or fmShareDenyWrite);

      ss := TStringList.Create;
      ss.LoadFromStream(Stream);
      conv := TConvert.Create(inputFormat)

      if ss.Count > 0 then begin
        aes  := TAESEncryption.Create;
        List := TStringList.Create;

        try
          aes.Unicode      := FUni;
          aes.InputFormat  := FInputFormat;
          aes.OutputFormat := FOutputFormat;
          aes.AType        := atECB;
          aes.KeyLength    := kl256;
          aes.Key          := conv.CharToFormat(FKey); 
          aes.PaddingMode  := TPaddingMode.PKCS7;
          aes.IVMode       := TIVMode.rand;
          try
            List.Text := aes.Decrypt(ss.Strings[0]);
          except
            if Assigned(OnDecryptError) then
              OnDecryptError(Self)
            else
              raise;
          end;
          SetStrings(List);
        finally
          aes.Free;
            conv.Free;
          ss.Free;
          Stream.Free;
          List.Free;
        end;
      end;
    end
    else
      Clear;
  finally
    Modified := False;
  end;

end;

No, sorry! Same Problem.

I can send you an encrypted File, if this helps.

It would, but I need a key too.
bernard[at]tmssoftware[dot]com

Hi, did you send me any data?

File and Password sended.

OK, solved. I will issue a revised version.

Issue was:

key := convIn.StringToByteArray(FKey, noUni);

The check on noUni/yesUni was not implemented. So, everything works fine as long as the key only contains characters less than 128, but no longer with other characters.

The bug is in MiscObj.

This was my create with 4.4.

IniFile:=TEncryptedIniFile.Create (SettingFilename,URPass32,MiscObj.TUnicode.yesUni,TConvertType.base64);

with 5.1. --> invalid operation -207
IniFile:=TEncryptedIniFile.Create (SettingFilename,URPass32,MiscObj.TUnicode.yesUni,TConvertType.raw,TConvertType.base64);

Try this:

var
  s: string;
  iLni: TEncryptedIniFile;
  MyKey: string;
  MyUni: TUnicode;
  Conv: TConvert;

begin
  s := '.\eMailSettings.ini'; // your file

  MyUni := yesUni;
  Conv := TConvert.Create(base64);
  MyKey := Conv.CharToFormat([*The password string you sent me*]);

  iLni := TEncryptedIniFile.Create(s, MyKey, MyUni, base64, base64);

  Conv.Free;
end;

Don't work for me. Are you able to decrypt my ini with my password?