Generic SQLite3 encryption codec C++ interface for encrypting database pages plus SQLite3 header.
- transparent usage
- interface: no hard-coded list of ciphers, use your crypto lib of choice
- full page encryption
- SQLite3 file header encryption
- key file support: long encryption key is stored separately, can be protected with a password)
- Initialize Git submodules:
git submodule update --init --recursive
- Link against the
cryptosqlite
CMake library target. - Implement
IDataCrypt
interface (for an example see test/TestCrypt.h or test/PlaintextCrypt.h)
Either:
int sqlite3_open_encrypted(const char *fileName, sqlite3 **db, const void *key, int keySize)
Or:
void sqlite3_prepare_open_encrypted(const char *fileName, const void *key, int keySize)
sqlite3_open
sqlite3_key
Note: Opening multiple encrypted databases at the same time is not thread-safe, but using them is.
cryptoSQLite automatically downloads, patches, and compiles the SQLite3
amalgamation source. This logic can be found in
sqlite/CMakeLists.txt. Updating the used SQLite3
version is achieved by simply modifying the variables in the aforementioned
CMakeLists.txt
.
The patch exposes a private method required for SQLite3 file header encryption. Due to its simplicity, the patch should work for newer SQLite3 versions without changes.
- SQLiteModernCPP: Modern SQLite3 wrapper
- cryptosqlitepp: Combines SQLiteModernCPP and cryptoSQLite into one Git repository for simplified usage.
The following alternative projects already supply ciphers to be used for encryption:
- SQLite3 Encryption: AES-based SQLite3 encryption codec depending on wxSQLite3
- SQLCipher: OpenSSL-based partially open source solution
This library is subject to the GNU Lesser General Public License v3.0 (GNU LGPLv3).
Copyright (C) 2017-2018 The ViaDuck Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.