This is not typically a question where to find a step-by-step guide, but rather the guide itself.
My intention with this post is to give others a hint, who have the same problems in compiling the driver-plugin as I just had recently.
相关问题
- QML: Cannot read property 'xxx' of undefin
- QTextEdit.find() doesn't work in Python
- “Zero out” sensitive String data in Swift
- SQL/SQL-LITE - Counting records after filtering
- High cost encryption but less cost decryption
How to build the Qt-SQL-driver-plugin 'QSQLCIPHER' for SQLite-DB with SQLCipher-extension using the Windows/MinGW-platform:
Qt 5.4.0 for Windows/MinGW
C:\Qt\Qt5.4.0
OpenSSL for Windows
C:\OpenSSL-Win32
C:\Windows\SysWOW64
)MinGW - Minimalist GNU for Windows
C:\MinGW
C:\MinGW
C:\MinGW
to the Qt-MinGW-directoryC:\Qt\Qt5.4.0\Tools\mingw491_32
Create file 'fstab' in
C:\Qt\Qt5.4.0\Tools\mingw491_32\msys\1.0\etc
Insert content as follows:
zlib-Library
C:\Qt\Qt5.4.0\Tools\mingw491_32\msys\1.0\bin
SQLCipher
C:\temp\sqlcipher-master
C:\OpenSSL-Win32\bin\libeay32.dll
toC:\temp\sqlcipher-master
C:\OpenSSL-Win32\lib\libeay32.lib
toC:\temp\sqlcipher-master
Build SQLCipher.exe
Execute MSYS:
C:\Qt\Qt5.4.0\Tools\mingw491_32\msys\1.0\msys.bat
Save the executable SQLite/SQLCipher-database e.g. to
C:\sqlcipher
C:\temp\sqlcipher-master\dist\bin\sqlcipher.exe
toC:\sqlcipher
.The file 'sqlcipher.exe' is the crypting equivalent to the non-crypting original command line interface 'sqlite3.exe'.
C:\temp\sqlcipher-master\sqlite3.dll
toC:\sqlcipher
.This file is the SQLite-library extended by the encryption.
Build Qt-QSQLCIPHER-driver-plugin
C:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\sqlcipher
Create the following three files within the new directory:
File 1: smain.cpp:
File 2: sqlcipher.pro
File 3: sqlcipher.json
C:\Qt\Qt5.4.0\5.4\Src\qtbase\src\sql\drivers\sqlite
toC:\Qt\Qt5.4.0\5.4\Src\qtbase\src\sql\drivers\sqlcipher
Customize file
C:\Qt\Qt5.4.0\5.4\Src\qtbase\src\sql\drivers\sqlcipher\qsql_sqlite.pri
The content of the file shall be like:
Create file 'sqlcipher.pri' in directory
C:\Qt\Qt5.4.0\5.4\Src\qtbase\src\3rdparty
with following content:Create and fill
C:\Qt\Qt5.4.0\5.4\Src\qtbase\src\3rdparty\sqlcipher
Create the two directories:
Copy the following files to
C:\Qt\Qt5.4.0\5.4\Src\qtbase\src\3rdparty\sqlcipher
:Copy the following files/directories to
C:\Qt\Qt5.4.0\5.4\Src\qtbase\src\3rdparty\sqlcipher\lib
:The directory now consists of the following files and directories:
Compile the QSQLCIPHER-driver-plugin for Qt:
C:\Windows\System32\cmd.exe /A /Q /K C:\Qt\Qt5.4.0\5.4\mingw491_32\bin\qtenv2.bat
Execute the following commands:
This builds the QSQLCIPHER-driver-plugin within the following directory:
C:\Qt\Qt5.4.0\5.4\mingw491_32\plugins\sqldrivers
.Create a new encrypted SQLite/SQLCipher-database
Create new SQLite-Plaintext-database 'plaintext.db' with a test table and some test data
Change directory to
C:\sqlcipher
, which contains 'sqlcipher.exe' and 'sqlite3.dll' (see above).C:\sqlcipher\plaintext.db
using a standard text-editor:Database scheme and test data can be read in plaintext.
Encrypting the plaintext-database
This will create the database
C:\sqlcipher\encrypted.db
using the key 'testkey'.C:\sqlcipher\encrypted.db
using a standard text-editor:Data are now encrypted.
https://www.zetetic.net/sqlcipher/sqlcipher-api/
Usage of the SQLite-database with SQLCipher-extension and access via Qt
Project file
Test-program 'main.cpp'
Compile and execute
When delivering a Qt-program do not forget the Qt-libraries, the platforms-libraries, SQL-driver-plugin 'qsqlcipher.dll' and the OpenSSL-library 'libeay32.dll'.
Example for the test program above:
Caution: The test program contains the key:
This key string in the binary file of the test program can easiliy be read using a hex-editor, which is, to my opinion, a lack in security:
For approaches how to solve this problem, ask the search engine of your own choice. ;-)
E.g. search for: hide string in executable