SQLite加密 wxSqlite3

来源:互联网 发布:小米手机数据连接不上 编辑:程序博客网 时间:2024/05/17 03:35

一直在网上搜wxSqlite3的文档,但是总找不到能真正解决问题的,就是一个简单的编译wxSqlite3自带的示例也出了老多问题,后来却发现,其实wxSqlite3的readme中已经有了详细的方法,哦,就在眼皮子底下!为了避免再一次的遗忘,就在这里暂作一个记录吧。


截至记录时间,wxSqlite3的版本号为2.1.1,Sqlite3的版本为3.7.6.2,这两个都可以直接在网上下载,
wxSqlite3的站点http://wxcode.sourceforge.net/components/wxsqlite3;
http://sourceforge.net/projects/wxcode/files/Components/wxSQLite3/
http://sourceforge.net/projects/wxsqlite/?source=directory
Sqlite3的站点http://www.sqlite.org/;

其中wxSqlite3自带了已编译的Sqlite3.7.6.1的DLL,当然,我的目的是自己编译静态的Lib,所以只能自己下来重新编译了。当然,我要的Lib是要带加密功能的,呵呵。

 

wxSQLite3 is a C++ wrapper around the public domain SQLite 3.x database and is specifically designed for use in programs based on the wxWidgets library.

wxSQLite3 does not try to hide the underlying database, in contrary almost all special features of the current SQLite version 3.7.10 are supported, like for example the creation of user defined scalar or aggregate functions. Since SQLite stores strings in UTF-8 encoding, the wxSQLite3 methods provide automatic conversion between wxStrings and UTF-8 strings. This works best for the Unicode builds of wxWidgets. In ANSI builds the current locale conversion object (wxConvCurrent) is used for conversion to/from UTF-8. Special care has to be taken if external administration tools are used to modify the database contents, since not all of these tools operate in Unicode resp. UTF-8 mode.

Since version 1.7.0 optional support for key based database encryption (128 bit AES) is also included. Starting with version 1.9.6 of wxSQLite3 the encryption extension is compatible with the SQLite amalgamation source and includes the extension functions module. Support for 256 bit AES encryption has been added in version 1.9.8.

从wxSqlite3 1.9.6开始,它的加密扩展就已经从C++转为纯C语言实现,因此现在可以直接编译SQLite
amalgamation source distribution实现了。只需要编译文件sqlite3secure.c即可,其已经include了所有需要的源文件。当然C++版本的文件也在codec目录(\sqlite3\secure\src\codec-c)中,但作者强烈的不推荐用它。


唠了这么多,现在正式开始。
1、下载sqlite-amalgamation-XXXXXX.zip,它已经包含了所有的源文件,也不需要另外的辅助工具了,解压到某一目录,如Sqlite3。
2、如果你下的sqlite-amalgamation-XXXXXX.zip没有makefile,那就自己做一个project吧,在VS2008里新建一个空工程,只加入sqlite3secure.c文件到工程即可,修改其中的#include "sqlite.c"的sqlite.c文件路径为上一步解压的文件的路径。
3、在配置属性中设置配置类型为静态库(.Lib),添加预处理
SQLITE_HAS_CODEC=1
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_CORE
THREADSAFE
SQLITE_SECURE_DELETE
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
4、编译生成Lib文件。
5、将生成的Lib文件取代wxsqlite3-2.1.1\sqlite3\lib中的sqlite3.lib文件,然后编译wxSqlite3为静态库,别忘了设置USE_DYNAMIC_SQLITE3_LOAD=0。

 

 

0 0
原创粉丝点击