打开微信加密数据库
微信 Android
数据库使用 SqlCipher
加密, 从代码来看, 是使用 sqlcipher 1
版本,
1 | private static final SQLiteCipherSpec qDP = |
使用诸如 DB Browser for SQLite , SQLiteStudio 等数据库管理软件都无法直接打开, 主要原因是连接参数不正确.
查看 SQLCipher 的源码发现设置 CipherVersion 为 1 时 , 会关闭 hmac, kdf_iter 为 4000.
1 | public SQLiteCipherSpec setSQLCipherVersion(int version) { |
在尝试 SQLiteStudio 配合 Cipher configuration 来建立链接, 还是失败 配置如下.
1 | PRAGMA kdf_iter = '4000'; |
查阅官方文档后发现有如下介绍:
PRAGMA cipher_compatibility: Force SQLCipher to operate with default settings consistent with that major version number for the current connection.
大概是说通过 PRAGMA cipher_compatibility
配置 , 设置这个版本号后, 会自动使用该版本默认的配置链接, 这样避免我们设置那些乱七八糟的配置.
1 | PRAGMA cipher_page_size = 1024; |
测试发现, OK~ 如下图.