Topic: Database encryption not working.

I have used Dmitri's sample code to encrypt my SQLite database.  It worked twice until I experimented with the code and now does not work at all in as much as the database is never decrypted.

The code

function OnSQLException(sender: TObject; Msg: string; SQL: string): boolean;
 begin
     if Pos('file is encrypted or is not a database', Msg)>0 then
     begin
         result := True;
         frmMain.SQLConnection.Connected := False;
         DecryptFileRC5('test.db', encDB);
     end;
 end;

EncDB is a constant with the decryption key.

What I did was just once change    result := True;   to False   just to check the error message was correct.

Changing it back to True now makes no difference the database displays the 'file is encrypted or is not a database' error form and then displays  some internal error messages that _roles and _users cannot be accessed and that there is already a user called admin (which of course is correct).


Next the login form is displayed which now fails as that  shows in plain text admin/admin and the password box displays everything in plain text

I have tried deleting the function for both decryption and in the form.onclose event changing the encryption code to the Decryption code  that does not work either.


I'm stumped as to what is wrong in the code.  I've checked through the DCU and form.xml files and can see nothing that is not being changed when the code is altered.


I wonder if the problem is caused by behind the scenes login code.


Any thoughts would be gratefully received.

On a clear disk you can seek forever