Hướng dẫn sqlite encryption php

I am considering supporting encrypted sqlite databases for a PHP application. I am using SQLite3 extension of PHP and it seems, that they already support an encryption method, at least SQLite3::__construct allows for an encryption-key to pass.

What i was not able to figure out is, which encryption library they are talking about in the documentation. By googling i found the following:

  • sqlcipher
  • sqlite see
  • sqlite crypt

What is not clear to me is:

  • how these libraries integrate with SQLite3
  • if they share compatibility to each other regarding to specifying the encryption key and setting up data access etc.
  • if i can automatically detect in my application if any and which encryption library my SQLite3 installation is supporting, so it would be possible for my application to support different encryption libraries

Any help is very much appreciated!

Hướng dẫn sqlite encryption php

PeeHaa

69.8k57 gold badges185 silver badges259 bronze badges

asked Mar 1, 2012 at 9:54

The SQLite3 library needs to be built with support for encryption. Those projects (and a few more: https://stackoverflow.com/a/5877130/502789) can be used to get an sqlite3.so/dll with encryption support.

So, the questions...

  1. They don't integrate with sqlite. They offer a replacement sqlite3 library with encryption support
  2. Vanilla SQLite3 provides the API required for encryption, but it's unimplemented. I believe SQLiteCrypt uses its own API and so won't work here (don't quote me on that).
  3. Your SQLite3 installation doesn't support it, you need to replace it with an SQLite3 library compiled with this feature (see the options I linked).

NB: I haven't used PHP + SQlite3 encryption.

answered Mar 3, 2012 at 14:28

OliJGOliJG

2,5401 gold badge15 silver badges15 bronze badges

As far as I'm aware, the password you pass to the PHP open will only work if you are using a version of SQLite compiled with encryption support (i.e. the encryption doesn't work in a default build).

We've had some users successfully use SQLCipher with PHP by building the PHP software with the SQLCipher codebase. More information is available in the thread here:

http://groups.google.com/group/sqlcipher/browse_thread/thread/6d77e4ef2a1530d7

answered Mar 1, 2012 at 15:34

1

answered Jul 7, 2012 at 0:52

Hướng dẫn sqlite encryption php

cking24343cking24343

3,0931 gold badge20 silver badges22 bronze badges

Please see my answer here: https://stackoverflow.com/a/49161716/9418360

SQLite3 has built-in interface for encryption. You need to enable it in config.m4 : -DSQLITE_HAS_CODEC=1 I have developed my own encryption based on AES. A few C files in /ext/sqlite3/libsqlite and it works great. The whole database file is encrypted, no need to send encrypted data from PHP. As soon as I have my code ready to publish will update this post. Cheers.

answered Mar 7, 2018 at 21:56

Not the answer you're looking for? Browse other questions tagged php encryption sqlite sqlcipher or ask your own question.

  • G.D.G. Software
    • Visit G.D.G. Software Website
    • Contact G.D.G. Software
    • About
  • HTML Executable
  • Paquet Builder
  • ExeOutput for PHP
  • XLS Padlock
  • GConvert
  • GSplit
  • Protect Ebook.net
  • Others
    • AniTuner
    • CHM To Exe
    • EPub To App