如何在命令行上解密加密的 sqlcipher 数据库文件? [英] How to decrypt an encrypted sqlcipher database file on command line?

查看:27
本文介绍了如何在命令行上解密加密的 sqlcipher 数据库文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题很简单

我拥有的是:

  • 我有一个使用 sqlcipher 加密的数据库文件.
  • 我也有用于加密这个数据库文件的密码

我需要的是:

  • 我需要解密数据库文件/需要一个未加密/未加密/解密的数据库文件.

解决方案

下载并构建 sqlcipher

--如果已经安装了 sqlcipher 则跳过这个

从目录中的 https://github.com/sqlcipher/sqlcipher 中提取代码(比如 ~/sqlcipher)

mkdir ~/bld;# 构建将发生在同级目录中cd ~/bld;# 切换到构建目录../sqlcipher/configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto";#配置sqlcipher进行安装;# 安装构建产品

将数据库解密为明文数据库

$ cd ~/;$ ./sqlcipher encrypted.dbsqlite>PRAGMA key = 'testkey';sqlite>ATTACH DATABASE 'plaintext.db' 作为纯文本 KEY '';-- 空密钥将禁用加密sqlite>SELECT sqlcipher_export('纯文本');sqlite>分离数据库明文;

在 ~/plaintext.db 中找到解密的数据库,您可以将其用于任何 sqlite 浏览器,例如 this.>

更新:2015 年 9 月

http://sqlitebrowser.org 现在支持 sqlcipher 数据库.这很整洁.

The question is simple

What I have is:

  • I have a database file which is encrypted using sqlcipher.
  • I also have the passphrase which was used to encrypt this db file

What I need is:

  • I need to decrypt the database file/ need a database file which is unencrypted/non encrypted/decrypted.

解决方案

Download and Build sqlcipher

--Skip this if sqlcipher is already installed

Pull the code from https://github.com/sqlcipher/sqlcipher in a directory (say ~/sqlcipher)

mkdir ~/bld;        #  Build will occur in a sibling directory
cd ~/bld;           #  Change to the build directory
../sqlcipher/configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"; 
                    #configure sqlcipher 

make install;       #  Install the build products

Decrypt the database to a plaintext database

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

Find the decrypted database at ~/plaintext.db which you can use with any sqlite browser like this.

Update : September 2015

http://sqlitebrowser.org now supports sqlcipher databases. That's neat.

这篇关于如何在命令行上解密加密的 sqlcipher 数据库文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆