سؤال

I am using ZeosDB component to access sqlite database. It works fine on an unencrypted db.

On a encrypted db i receive : file is encrypted or not a database. Eaven if I set the password.

Is the DLL file I use wrong ? I use the last dll from the official page.It does not support encryption by default ?

هل كانت مفيدة؟

المحلول

There are several encryption schemes on SQLite3.

Among them, you have:

  • The official not free encryption library from SQLite3 authors, named SQLite Encryption Extension (SEE): just pay and use the dll, and modify the initialization to set the database key;
  • Open Source SQLCipher;
  • WXSQlite3 wrapper;
  • For Delphi, our Open Source static-linked version included in our mORMot (with a custom encryption) - static linking allow you not to use an external sqlite3.dll so it will help making your deployment and support easier - it features easy switch to MS SQL, Oracle or OleDB/ODBC with the same source code from Delphi 5 up to XE3 and has great speed;
  • See the link above.

ZeosDB SQLite3 level handle none of them.

The SQlite3 API driver (unit ZPlainSqLiteDriver) does not contain the cyphering. So you will have to change it. Or switch to another wrapper which support encryption APIs.

نصائح أخرى

Recently I had the same problem (using UniDac). The official DLLs do not support encryption. There are a couple of libraries that include encryption, but they are not interchangeable. I.e. DB encryped with one SQLite DLL cannot be decrypted with the other distribution. I think your case is the same.

My solution was:

  • Downloaded the ...static bunde... package (x86, x64) for .NET - this supports encryption (windows DPAPI I think)
  • Renamed System.Data.SQLite.dll to SQLite3.dll -> this DLL is native DLL and supports enc/dec
  • In the folder of my DBMS I replaced SQLite DLL with the extracted above

This way DBMS encrypts using the new DLL, and your program can decrypt it using the same version of the DLL.

You can also take a look at:

Notes:

  • Also make sure you copy SQLite3.dll to your program directory. Many other products use SQLite and are in the %PATH% so there's no guarantee the "right" SQLite3.dll will be loaded by your executable. Interesting solution can be found here;
  • Consult the license to see if you can use .NET's version for free, because of this.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top