加密你的SQLite
转自王中周的个人博客
关于SQLite
- RC4
- AES-128 in OFB mode
- AES-128 in CCM mode
- AES-256 in OFB mode
asier to setup, saving many steps in project configuration
pre-built with a modern version of OpenSSL, avoiding another external dependency
much faster for each build cycle because the library doesn't need to be built from scratch on each compile (build time can be up to 95% faster with the static libraries)
|
- NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
- stringByAppendingPathComponent: @"cipher.db"];
- sqlite3 *db;
- if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
- const char* key = [@"BIGSecret" UTF8String];
- sqlite3_key(db, key, strlen(key));
- int result = sqlite3_exec(db, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL);
- if (result == SQLITE_OK) {
- NSLog(@"password is correct, or, database has been initialized");
- } else {
- NSLog(@"incorrect password! errCode:%d",result);
- }
- sqlite3_close(db);
- }
- $ ./sqlcipher plaintext.db
- sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'testkey';
- sqlite> SELECT sqlcipher_export('encrypted');
- sqlite> DETACH DATABASE encrypted;
- $ ./sqlcipher encrypted.db
- sqlite> PRAGMA key = 'testkey';
- sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY ''; -- empty key will disable encryption
- sqlite> SELECT sqlcipher_export('plaintext');
- sqlite> DETACH DATABASE plaintext;
加密你的SQLite的更多相关文章
- 编译带加密功能的sqlite
以为编译wxsqlite是很难的事情,竟然这么顺利. 1.下载wxsqlite代码,解压(wxcode.sourceforge.net/components/wxsqlite3/) 2.下载Prema ...
- SQLite学习笔记(十)&&加密
随着移动互联网的发展,手机使用越来越广泛,sqlite作为手机端存储的一种解决方案,使用也非常普遍.但是sqlite本身安全特性却比较弱,比如不支持用户权限,只要能获取到数据库文件就能进行访问:另外也 ...
- SQLite XXTea加密学习
这几天优化数据库读写,移植了xxtea加密到最新的数据库sqlite 3.12.2里,一些好文章放在这里.移植后,数据库读写性能异常优秀! 这几天又发现,数据库还是发生了无法写入情况,数据库崩溃掉了. ...
- SQLite加密的方法(c#)
http://blog.csdn.net/xjbx/article/details/2712236 设置下密码就可以了 http://bbs.csdn.net/topics/380018685 编译为 ...
- SQLite数据库的加密【转】
1.创建空的SQLite数据库. //数据库名的后缀你可以直接指定,甚至没有后缀都可以 //方法一:创建一个空sqlite数据库,用IO的方式 FileStream fs = File.Create( ...
- Sqlite数据库的加密
最近在做一个winform的程序,考虑用Sqlite的数据库,小巧而实用,比Access强多了,不过需要加密,不过free版本没有实现加密,有一些c++的实现:比如:http://www.sqlite ...
- 在C#中,如何连接已加密的Sqlite数据库
对数据加密分两种,一种是对数据库本身进行加密,另一种是对数据表中的数据进行加密, 如果SQLite数据库加密,我这里使用的一个管理工具叫SQLiteDeveloper,如下就可以加密数据库 , 如果在 ...
- c# sqlite 数据库加密
c# sqlite 数据库加密 2010-05-29 10:55 用了ADO.NET 2.0 SQLite Data Provider这样可以直接利用它来创建一个加密的sqlite数据库.有关c#代码 ...
- SQLite加密方式 [转]
关于SQLite SQLite是一个轻量的.跨平台的.开源的数据库引擎,它的在读写效率.消耗总量.延迟时间和整体简单性上具有的优越性,使其成为移动平台数据库的最佳解决方案(如iOS.Android). ...
随机推荐
- Android(java)学习笔记138:html嵌入到java显示乱码
解决方案: 使用 loadData方法是中文部分会出现乱码,即使指定“utf-8”.“gbk”.“gb2312”也一样. webView.getSettings().setDefaultTextEnc ...
- 编程以外积累: 如何给项目生成类似VS2008的说明文档
1:[下载] 目前微软提供的官方开源工具 Sandcastle结果跑到项目中一看,抬头就来了这么一段: The Sandcastle CodePlex project is no longer und ...
- c结构体初始化问题
结构体中的数组的初始化问题 我的代码 C/C++ code #include <stdio.h> #include <stdlib.h> struct a { int leng ...
- 安卓UI美化_drawable
UI美化 drawable资源 ------------------------------------------state drawable资源在不同状态下显示不同的图片在<selector ...
- 利用Qt制作一个helloworld
使用QT创建第一个 工程: 1.打开应用程序: 2.单击画面中间偏上的 New Project按钮.[要学习使用啊~,传说它的跨平台行很好,QQ就是用它编辑的.] 3.直接点击右下角的选择 按钮. 4 ...
- HDU-1060(简单数学)
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) P ...
- 【MINA】字节序知识
字节序,分为高位在前和低位在前,说白了就是先从低操作还是从高位操作 java和网络的字节序是一致的,都是高位在前,这意味着java端序列化和反序列化时不用关心字节序的问题, 那问题是,那讨论字节序有什 ...
- sql: 生日三个月内有效
DECLARE @birthday datetime,@stat datetime,@end datetime,@statbirthday datetime,@endbirthday datetime ...
- 20160410javaweb之JDBC---DBUtils框架
DBUtils 1.DbUtils 工具类 2.QueryRunner -- 两行代码搞定增删改查 (1)QueryRunner() --需要控制事务时,使用这组方法 int update(Conne ...
- HeaderViewListAdapter cannot be cast to listAdapter问题原因及解决办法
[o] 在listView中添加leaderView 和footerView的时候要注意在setAdapter之前调用,不然会报如下异常: listAdapter cannot be cast to ...