pc 制作数据,然后通过sqlcipher 在PC上面加密

android 通过sqlcipher来读取解密数据。

通信简单地修改xutil,就可以让xutil支持sqlcipher,创建与读取加密数据库。

http://blog.csdn.net/zhanghw0917/article/details/39343057
sqlcipher 加密数据库后想要查看数据库 ,需使用使用sqlcipher windows 命令工具

注意 使用的工具也分版本,要与加密数据库的版本对应起来,否则查看不到表

下载地址:

对应2.x

http://download.csdn.net/detail/zhanghw0917/7931759

3.01版本

http://download.csdn.net/detail/zhanghw0917/7931909

转载 http://www.cnblogs.com/treecat-roboto/p/3873707.html

加密后使用命令行还是可以查看滴

1. 创建加密数据库
$ sqlcipher encrypted.db
SQLCipher version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> PRAGMA key = 'thisiskey';
sqlite> create table encrypted (id integer, name text);
sqlite> .schema
CREATE TABLE encrypted (id integer, name text);
sqlite> .q

2. 打开加密数据库
$ sqlcipher encrypted.db
SQLCipher version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> PRAGMA key = 'thisiskey';
sqlite> .schema
CREATE TABLE encrypted (id integer, name text);

3. 修改数据库密码

sqlite> PRAGMA rekey = 'newkey';

4. 加密已有的数据库
$ sqlcipher banklist.sqlite3
SQLCipher version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'thisiskey';
sqlite> SELECT sqlcipher_export('encrypted');
sqlite> DETACH DATABASE encrypted;

5. 解密数据库
$ sqlcipher encrypted.db
SQLCipher version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> PRAGMA key = 'thisiskey';
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;

转自 : http://my.oschina.net/kjpioo/blog/149290

satckoverflow.com上有人提到过在

sqlite> sqlcipher-shell32.exe test.db

sqlite> PRAGMA KEY = '12345';

给刚打开的数据库设置密码后,马上接着往数据库执行create table和 insert操作。最后用

sqlite> .e

退出该数据库。但是下次再用

sqlite> sqlcipher-shell32.exe test.db

登录,在输入密码前执行了.schema等其他操作

sqlite>.schema

Error: file is encrypted or is not a database

sqlite> PRAGMA KEY = '12345';

Error: file is encrypted or is not a database

遭到提示:Error: file is encrypted or is not a database

根据官方以上英文描述,这个问题就是因为操作上没有遵循just-in-time key derivation的要求,没有首先输密码解密再进行其他操作。

有图为证:

----------------以下为正确操作过程:

SQLite version 3.7.15.2 2013-01-09 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> PRAGMA KEY = '12345';
sqlite> .schema
CREATE TABLE t(name text);
sqlite> select * from t;
n1
sqlite>

----------------以下为错误操作过程:

Enter SQL statements terminated with a ";"
sqlite> .schema
Error: file is encrypted or is not a database
sqlite> PRAGMA KEY = '12345';
sqlite> .schema
Error: file is encrypted or is not a database
sqlite>

确实如此。

以上过程你可以自己亲自验证以下。

注意:通过命令行( sqlcipher-shell32.exe) 执行命令,与通过sqlite3 api调用操作sqlite3数据库,是一样的

更多相关文章

  1. Appium(七):Appium API(一) 应用操作
  2. android的存储GreenDao数据库
  3. 基于安卓5.0 material design仿ios界面简单计算器
  4. 通过WifiManager可以实现对wifi进行操作,实现wifi自动连接等一些
  5. android studio git 上传代码,分支,tag,回退操作
  6. Android蓝牙开发(三):操作步骤
  7. 使用SQLiteOpenHelper 和使用ContentProvider。
  8. Android后台开启服务默默拍照
  9. lobiner 关于android中的sqlite数据库操作

随机推荐

  1. android:editable和android:enabled的区
  2. android TextView中多个空格只显示一个
  3. Android——TV真机调试apk(android:shared
  4. android 网络访问-图片处理优秀开源项目
  5. android获取GPS位置信息
  6. BaseAdapter与ListView解析
  7. 2018-03-10—Android六大布局之LinearLay
  8. PreferenceActivity和PreferenceFragment
  9. Android 4游戏编程入门经典
  10. Android: Android Bluetooth