SQLite加密 wxSqlite3

前端之家收集整理的这篇文章主要介绍了SQLite加密 wxSqlite3前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一直在网上搜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。

原文链接:https://www.f2er.com/sqlite/200199.html

猜你在找的Sqlite相关文章