4

I can open my encrypted sqlite database with sqlite maestro application but I can not with fiedac I get this error

[FireDAC][Phys][SQLite] ERROR: Cipher: Invalid password is specified or DB is corrupted

Here is my data module unit:

object DM: TDM
  OldCreateOrder = False
  Height = 306
  Width = 468
  object FDConnection1: TFDConnection
    Params.Strings = (
      'Database=C:\myapps\mydb.db'
      'Password=mypass'
      'DriverID=SQLite')
    LoginPrompt = False
    Left = 48
    Top = 16
  end

I wrote the encryption key as a password but when I not type any password I get error:

[FireDAC][Phys][SQLite] ERROR: file is encrypted or is not a database.

What is the problem ?

zac
  • 4,495
  • 15
  • 62
  • 127
  • 1
    You missed to tell FireDAC which encryption you use. Use the format `:` like e.g. `aes-256:MyPassword` for the `Password` connection parameter. Consult [connection definition parameters](http://docwiki.embarcadero.com/RADStudio/en/Connect_to_SQLite_database_(FireDAC)#Connection_Definition_Parameters) for that. I cannot give you a direct answer as you haven't mention encyption that you actually use. – Victoria Apr 30 '18 at 22:49
  • @Victoria I get invalid password when I do so – zac Apr 30 '18 at 22:55
  • Well, then you have used invalid password. But you must use that format (unless you used AES-256), that is what I'm sure about. If you tell us the exact steps that you followed, I can try to simulate with SQLite Maestro trial on VM in a few hours (as it's 1AM where I live :) – Victoria Apr 30 '18 at 23:03
  • 1
    @Victoria It is the correct password I use with sqlite maestro. I only dropped `fdconnection` component , right click and I set the parameters above: database name, password and driver ... take your time we are in same time zone btw ... thanks – zac Apr 30 '18 at 23:07

1 Answers1

4

Found the problem. According to the documentation:

The encrypted database format is not compatible with other similar SQLite encryption extensions. This means that you cannot use an encrypted database, encrypted with non-FireDAC libraries. If you need to do this, then you have to decrypt a database with an original tool and encrypt it with FireDAC.

I can not encrypt with SQLite Maestro (different library) and open it in FireDAC so I must decrypt it then encrypt the database using FireDAC. I used the encryption sample the come with Delphi and now I can open it with FireDAC.

Victoria
  • 7,822
  • 2
  • 21
  • 44
zac
  • 4,495
  • 15
  • 62
  • 127
  • 1
    Hope you won't conquer my temple with your new punk helmet because of my edit :) It is the correct answer! Please, don't forget to accept it.. – Victoria May 02 '18 at 00:10
  • @Victoria lol I am a trooper like you. Sure will select the answer just there is 2 days forced period before I can do so. Thanks alot Victoria you always help me. – zac May 02 '18 at 01:17
  • Ah, there is some answer accepting period. Forgot that thing. Sorry. And I'm glad I was useful at some time; not this time though :) – Victoria May 02 '18 at 02:00
  • of course you did. You inspired me to look into documentation and also you edited my bad writing :) – zac May 02 '18 at 02:03
  • @Victoria plz update your profile with your twitter, linkedin etc... I would like to follow you. – zac May 02 '18 at 02:39
  • Sorry, I have no such thing like that. I'm just a free (lancer :) And I'll try to update my profile about it soon. – Victoria May 02 '18 at 02:46
  • @Wel Hello, I also have a problem, Is the solution to use sqllite without username and password? – Pointer May 29 '19 at 09:28
  • @Wel How encrypt the database using FireDAC? Any example? – Pointer May 29 '19 at 13:10