Encrypt/Decrypt SQLite-database and use it "on the fly" Encrypt/Decrypt SQLite-database and use it "on the fly" sqlite sqlite

Encrypt/Decrypt SQLite-database and use it "on the fly"


There is no built in support, that being said you do have options.

1) You can encrypt/decrypt all of your strings yourselves, but this is a lot of work, is not transparent, and won't allow you to do things like searching in the database.

2) SQLiteCrypt and SQLCipher do what you're looking for.

You can use them almost entirely transparent and typically they are said to have only about 5% overhead compared without encryption.


I would suggest using a library that does this for you, rather than building in your own encryption.

http://www.hwaci.com/sw/sqlite/see.htmlor http://sqlite-crypt.com/documentation.htm

Use your favorite search engine for some alternatives.


The best way I can think about is to use FUSE - "filesystems in user-land" - available for Linux , Mac OS X and other systems, or a different encrypted file-system. This will make SQLite see it as unencrypted while being physically encrypted on the disk. By playing with the permissions you can make sure people cannot access the unecrypted file system.

I'm not sure if SQLite has a way to over-ride the low-level read/write routines which will allow you to implement the encryption on the fly without filesystem games. At least I never needed to do that. You may wish to search for such a feature request and file one it if it's not in the SQLite issue tracker.