天天看點

sqlcipher 資料庫解密

sqlcipher 資料庫解密

使用 sqlcipher.exe 可以在輸入密碼後,檢視加密資料庫的内容。

使用sqlcipher windows 指令工具

注意 使用的工具也分版本,要與加密資料庫的版本對應起來,否則檢視不到表

下載下傳位址:

解密時要用與加密時相同的版本

https://github.com/sqlcipher/sqlcipher/releases

https://github.com/CovenantEyes/sqlcipher-windows/releases

加密後使用指令行還是可以檢視滴

  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’;

  1. 加密已有的資料庫

    $ 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;

  2. 解密資料庫(生成無密碼的資料庫: 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;

繼續閱讀