加密版Sqlite(集成CppSqlite)



【本文来由】
1.官方免费版不支持加密解密。
2.网络无言简意赅的操作步骤指导。
3.网络上都是一些dll和lib文件,没有项目文件和源码。
4.网络上的编译方法非官方方式且不具有通用性,明显没有读官方的readme。
5.网络上编译的dll文件和lib文件还要依赖wxWidgets库,本文的方法不依赖wxWidgets库,只是从wxWidgets库中提取了加密核心文件。原因来自于官方说明:

Starting with the release of wxSQLite3 1.9.6 the encryption extension has
been converted from C++ to pure C and is now compatible with the SQLite
amalgamation source distribution. Just compile the file sqlite3secure.c
which includes all required source files.
(The C++ version is still
included in directory codec, but it is deprecated and it's use is not
recommended anymore.)


【编译步骤】
1.下载wxSqlite3的最新版,地址在:http://wxcode.sourceforge.net/components/wxsqlite3
2.下载premake4的最新版,当前是beta4.4,一开始我下载的正式版4.3,结果编译wxsqlite3时,提示vpaths错误,查半天官方文档发现,只有4.3以上的版本才支持这个扩展特性。

The vpaths function places files into groups or "virtual paths", rather than the default behavior of mirroring the filesystem in IDE-based projects. So you could, for instance, put all header files in a group called "Headers", no matter where they appeared in the source tree.

vpaths { ["group"] = "pattern(s)" }

Note that Lua tables do not maintain any ordering between key-value pairs, so there is no precedence between the supplied rules. That is, you can't write a rule that rewrites the results of an earlier rule, since there is no guarantee in which order the rules will run.

Added in Premake 4.4.

参考地址:http://industriousone.com/vpaths

3.下载sqlite-amalgamation-201401290146,复制sqlite3.h和sqlite3.c这两个文件到wxsqlite3-3.0.6.1\wxsqlite3-3.0.6\sqlite3\secure\src目录下,以保证sqlite是最新版。
4.复制premake4.exe到wxsqlite3-3.0.6.1\wxsqlite3-3.0.6\sqlite3\secure路径(premake4用来生成各种编译器的项目工程文件,具体说明查看官方。)
5.cmd切换到wxsqlite3-3.0.6.1\wxsqlite3-3.0.6\sqlite3\secure下,执行命令premake4 --os=windows --platform=x32 vs2008(具体参数请执行premake4 --help)
6.执行后可以发现当前目录下生成了SQLite3.sln,运行后有三个工程sqlite3dll、sqlite3lib、sqlite3shell,其中sqlite3lib是静态库工程。编译所有工程及配置文件备用。
7.sqlite3lib又分四个编译配置,此处我们用aes256 debug 和aes256 release。
8.复制wxsqlite3-3.0.6.1\wxsqlite3-3.0.6\sqlite3\secure\aes256\lib\debug\sqlite.lib到CppSQLite3_2\Common目录下改名为sqlite3_d.lib
  复制wxsqlite3-3.0.6.1\wxsqlite3-3.0.6\sqlite3\secure\aes256\lib\release\sqlite.lib到CppSQLite3_2\Common目录下改名为sqlite3_r.lib
9.安装sqliteexpert,替换前面生成的wxsqlite3-3.0.6.1\wxsqlite3-3.0.6\sqlite3\secure\aes128\dll\release\sqlite.dll替换sqliteexpert根目录下的sqlite3.dll
10.打开sqliteexpert,在工具\选项\data\SQLite Library
里选择第二项:sqlite3.dll(version 3.8.2) supports
fts3,fts4,rtree,encryption这样选择的目的是让sqliteexpert使用我们的dll进行管理数据库,支持我们自己的数据库,否则是无法打开我们创建的数据库的。
11.cppsqlite+aes256sqlite的集成已经完毕,整套方案配置完毕,启动cppsqlite工程进行测试。
【其它说明】
其中支持加密函数的CppSQLite版本来自于http://emonkey.iteye.com/blog/1613282(底部有链接可以下载)
本文作者:能哥(627660966@qq.com)



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值