Qt Sqlite加密数据库驱动源代码

上传者: zzhouqianq | 上传时间: 2021-08-07 19:26:59 | 文件大小: 1.35MB | 文件类型: 7Z
这是我工作了一天的成果,压缩包内包括Qt sqlite加密驱动所有的代码,以及一个调用例程,还有一个sqlite3shell.exe工具,用于加密数据库命令行下的分析。 使用这个加密驱动很简单,只需以下3步: 1. 将驱动的代码复制到你的app文件夹(共2个文件夹) 2. 在app的pro文件中加入 include(wxsqlite3/wxsqlite3.pri) include(zsqlitecipherdriver/zsqlitecipherdriver.pri) 3. 在需要的地方加入#include "zsqlitecipherdriver.h",这样就可以使用ZSQLiteCipherDriver类了,这个类是继承自QSqlDriver。所以可以传递给 QSqlDatabase::addDatabase。 详细的可以查看压缩包内源码。之后,main函数就可以这么使用sqlite的加密驱动: ZSQLiteCipherDriver *driver = new ZSQLiteCipherDriver(); QSqlDatabase db = QSqlDatabase::addDatabase(driver); db.setDatabaseName("test.db"); db.setPassword("123"); db.open(); ... 加密驱动的稳定性没有问题,是我从Qt的开源代码中,找到Sqlite没加密的驱动部分,然后修改的。修改的内容不多,最重要的是在数据库的open时,加入了sqlite3_key的调用,实现加密。 底层的加密实现,是来自wxsqlite3-3.0.6。这个我修改了一个宏定义,让其加密方式采用了AES256,而不是原来的AES128。 例程中包括了3个实用的函数,分别用来以某一密码打开或创建一个数据库,判断数据库是否处于解密状态,以及修改数据库密码。 sqlite3shell.exe跟官方提供的sqlite3.exe使用方法一样。只不过对于加密数据库,需要在对数据库进行任何操作前,先执行“PRAGMA key=xxx;”。通过这种方式输入数据库密码。检验之前的密码是否正确可以在命令行中键入“.databases”,如果没有错误提示,那就是解密成功了;如果密码错误,只能关闭sqlite3shell.exe,从头尝试了。 虽然这个资源,要的分数确实有点多,不过评价之后就能返还的。我相信这个资源值这个价值!下载后在Qt5上可以直接编译。不需要任何修改。Qt4上没试过,不承诺一定可用,但是应该没问题。

文件下载

资源详情

[{"title":"( 20 个子文件 1.35MB ) Qt Sqlite加密数据库驱动源代码","children":[{"title":"ZSqliteCipherDriverExample","children":[{"title":"wxsqlite3","children":[{"title":"codec.c <span style='color:#111;'> 18.86KB </span>","children":null,"spread":false},{"title":"rijndael.c <span style='color:#111;'> 99.94KB </span>","children":null,"spread":false},{"title":"sqlite3.h <span style='color:#111;'> 345.18KB </span>","children":null,"spread":false},{"title":"rijndael.h <span style='color:#111;'> 6.59KB </span>","children":null,"spread":false},{"title":"sqlite3secure.c <span style='color:#111;'> 2.14KB </span>","children":null,"spread":false},{"title":"sha2.h <span style='color:#111;'> 5.44KB </span>","children":null,"spread":false},{"title":"wxsqlite3.pri <span style='color:#111;'> 384B </span>","children":null,"spread":false},{"title":"sqlite3.c <span style='color:#111;'> 4.91MB </span>","children":null,"spread":false},{"title":"codecext.c <span style='color:#111;'> 10.89KB </span>","children":null,"spread":false},{"title":"sha2.c <span style='color:#111;'> 32.38KB </span>","children":null,"spread":false},{"title":"codec.h <span style='color:#111;'> 3.21KB </span>","children":null,"spread":false}],"spread":false},{"title":"sqlite3shell.exe <span style='color:#111;'> 831.50KB </span>","children":null,"spread":false},{"title":"ZSqliteCipherDriverExample.pro <span style='color:#111;'> 219B </span>","children":null,"spread":false},{"title":"main.cpp <span style='color:#111;'> 4.01KB </span>","children":null,"spread":false},{"title":"zsqlitecipherdriver","children":[{"title":"zsqliteciphercachedresult.h <span style='color:#111;'> 3.41KB </span>","children":null,"spread":false},{"title":"zsqliteciphercachedresult.cpp <span style='color:#111;'> 8.33KB </span>","children":null,"spread":false},{"title":"zsqlitecipherdriver.pri <span style='color:#111;'> 277B </span>","children":null,"spread":false},{"title":"zsqlitecipherdriver.cpp <span style='color:#111;'> 24.48KB </span>","children":null,"spread":false},{"title":"zsqlitecipherdriver.h <span style='color:#111;'> 4.01KB </span>","children":null,"spread":false}],"spread":true},{"title":"readme.txt <span style='color:#111;'> 1.77KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

  • y281252548 :
    赞一个,很好用
    2020-08-12
  • sincelh :
    挺好的,使用qt5.7静态库编译通过
    2018-06-21
  • itas109 :
    经测试可用。。。。。。
    2017-11-29
  • c_1_c_2_c_3_c_4 :
    资源不错,在5.6.0上面编译通过! 遗憾的是只支持 #define CODEC_TYPE_AES128 1 #define CODEC_TYPE_AES256 2 两种加密方法。 加密后只能用这个
    2016-07-09
  • liuguangzhou123 :
    很好,qt5.6.0顺利编译通过并运行
    2016-06-09

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明