I\'m just learning to use SQLite and I was curious if such is possible:
Encryption of the database file?
Password protect opening of the dat
Well, SEE
is expensive. However SQLite
has interface built-in for encryption (Pager). This means, that on top of existing code one can easily develop some encryption mechanism, does not have to be AES
. Anything really.
Please see my post here: https://stackoverflow.com/a/49161716/9418360
You need to define SQLITE_HAS_CODEC=1 to enable Pager encryption. Sample code below (original SQLite
source):
#ifdef SQLITE_HAS_CODEC
/*
** This function is called by the wal module when writing page content
** into the log file.
**
** This function returns a pointer to a buffer containing the encrypted
** page content. If a malloc fails, this function may return NULL.
*/
SQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){
void *aData = 0;
CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);
return aData;
}
#endif
There is a commercial version in C language
for SQLite
encryption using AES256 - it can also work with PHP
, but it needs to be compiled with PHP
and SQLite
extension. It de/encrypts SQLite
database file on the fly, file contents are always encrypted. Very useful.
http://www.iqx7.com/products/sqlite-encryption