我在 android 中使用 SQLCipher 开发了应用程序。这是将数据库文件保护到应用程序中的安全方法。加密工作正常,但我想解密加密的数据库文件并想查看 SQLite 浏览器。
实际上我有很多表格及其数据可用。现在如果我想查看加密的数据库数据,没有办法查看它(只有日志可用于查看数据)。但是使用 SQLite 浏览器我看不到它。
我正在使用"info.guardianproject.database.sqlcipher.SQLiteDatabase"
我尝试了很多方法来解密它并查看 SQLite 浏览器,但它给出错误“发生错误:文件不是 sqlite3 数据库”。
谁能帮我解密加密的数据库文件。
或者我应该复制加密数据库文件并使用 "info.guardianproject.database.sqlcipher.SQLiteDatabase" 解密并使用它来查看所有表。
谢谢,
米沙尔沙阿
最佳答案
我通过从设备中提取数据库并解密来解决这个问题。下面的脚本将生成一个解密的数据库文件。这个文件可以用 SQLite-viewer 打开。
解密.sh
#!/bin/bash
# Bashscript to decrypt databases
echo "pull db from device.."
adb pull /data/data/com.example/databases/database.db
echo "removing previous decrypted db, if existent.."
rm -r decrypted_database.db
echo "decrypting database.db into decrypted_database.db"
sqlcipher -line database.db 'PRAGMA key = "encryption_key";ATTACH DATABASE "decrypted_database.db" AS decrypted_database KEY "";SELECT sqlcipher_export("decrypted_database");DETACH DATABASE decrypted_database;'
应该在你的路径中:
在脚本中替换:
- com.example 加上你的包名
- database.db 名称为数据库文件
- encryption_key带加密密码
注意: 设备应该被 Root
关于android - 如何解密android中的SQLCipher加密文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15382081/