sqlcipher 数据库解密
使用 sqlcipher.exe 可以在输入密码后,查看加密数据库的内容。
使用sqlcipher windows 命令工具
注意 使用的工具也分版本,要与加密数据库的版本对应起来,否则查看不到表
下载地址:
解密时要用与加密时相同的版本
https://github.com/sqlcipher/sqlcipher/releases
https://github.com/CovenantEyes/sqlcipher-windows/releases
加密后使用命令行还是可以查看滴
创建加密数据库
$ 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
打开加密数据库
$ 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);
修改数据库密码
sqlite> PRAGMA rekey = ‘newkey’;
加密已有的数据库
$ 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;
解密数据库(生成无密码的数据库: plaintext.db)
$ sqlcipher-shell32 encrypted.db
sqlite> PRAGMA key = ‘thisiskey’;
sqlite> ATTACH DATABASE ‘plaintext.db’ AS plaintext KEY ‘’;
sqlite> SELECT sqlcipher_export(‘plaintext’);
sqlite> DETACH DATABASE plaintext;