How to decrypt an encrypted sqlcipher database file on command line?

前端 未结 4 1951
北恋
北恋 2020-12-07 18:04

The question is simple

What I have is:

  • I have a database file which is encrypted using sqlcipher.
  • I also
4条回答
  •  北海茫月
    2020-12-07 18:51

    Building on the previous answers , I have a comprehensive answer. I have the configuration- OS X version - 10.10.4 Steps : 1. Donwload and build OpenSSL code:

    $ curl -o openssl-1.0.0e.tar.gz https://www.openssl.org/source/openssl-1.0.0e.tar.gz
    $ tar xzf openssl-1.0.0e.tar.gz
    $ cd openssl-1.0.0e
    $ ./Configure darwin64-x86_64-cc
    $ make
    
    1. Download and build SQLCipher code.

    In another directory,

    $ git clone https://github.com/sqlcipher/sqlcipher.git
    $ cd sqlcipher
    

    Change '/path/to/libcrypto.a' in the following command to your path

    $ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="/path/to/libcrypto.a"
    $ make
    
    1. Decrypt to plaintext database (As illustrated in previous post by Vinay)

      $ cd ~/;
      $ ./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;
      

    Tis should help you decrypt the encrypted file...

提交回复
热议问题