Cipher: Failed to reserve envelope space

I am trying to encrypt / decrypt a SQLite database via FireDAC in a Delphi XE7 application running on Windows 7 (64 bit).

The code looks like this:

Procedure TMain.ActionBtnClick(Sender: TObject);
Begin
If ActionBtn.Caption = 'Encrypt' Then
   Begin
   SetPassword;
   FDSQLiteSecurity.SetPassword;
   End
Else
   FDSQLiteSecurity.RemovePassword;
SetStatus;
End;

Procedure TMain.DBNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
Begin
If OpenDialog.Execute Then
   Begin
   DBName.Text := OpenDialog.FileName;
   SetStatus;
   End;
End;

Procedure TMain.FormClose(Sender: TObject; Var Action: TCloseAction);
Var
   Reg: TRegistry;
Begin
Reg := TRegistry.Create;
Try
   Reg.OpenKey('\SQLiteSecurity', True);
   Reg.WriteString('Database', DBName.Text);
Finally
   Reg.CloseKey;
   Reg.Free;
End;
End;

Procedure TMain.FormShow(Sender: TObject);
Var
   Reg: TRegistry;
Begin
DBStatus.Caption := '';
Reg := TRegistry.Create;
Try
   Reg.OpenKey('\SQLiteSecurity', True);
   If Reg.ValueExists('Database') Then
      Begin
      DBName.Text := Reg.ReadString('Database');
      SetStatus;
      End;
Finally
   Reg.CloseKey;
   Reg.Free;
End;
End;

Procedure TMain.SetPassword;
Var
   s: String;
Begin
FDSQLiteSecurity.Database := DBName.Text;
BEK(s);
FDSQLiteSecurity.Password := s;
End;

Procedure TMain.SetStatus;
Begin
DBStatus.Caption := FDSQLiteSecurity.CheckEncryption;
If DBStatus.Caption = '<unencrypted>' Then
   ActionBtn.Caption := 'Encrypt'
Else
   ActionBtn.Caption := 'Decrypt';
End;

      

When you try to encrypt on a line that reads "FDSQLiteSecurity.SetPassword;", you receive the following error message:

[FireDAC] [Phys] [SQLite] ERROR: Cipher: Failed to reserve envelope space.

I tried to find the meaning of this error message with no success. Does anyone know what the SQLite error message is trying to tell me?

+3


source to share


1 answer


TFDSQLiteSecurityOptions FireDAC.Phys.SQLite.TFDSQLiteSecurity.Options

Have you installed the option soSetLargeCache

?

Use the Options property to specify database encryption options.



Due to the existing SQLite encryption limitation, calling SetPassword / ChangePassword / RemovePassword with the call will fail if the database contains blob fields with a value greater than 1 DB page and the database does not fit into the SQLite cache.

If the parameter is soSetLargeCache

set, then SetPassword / ChangePassword / RemovePassword automatically sets the cache size larger than the database size to completely insert the database into memory.

If the size of the database is larger than the available system memory, then the corresponding call fails.

+1


source







All Articles