MacBook 怎么打开微信的加密数据库

微信Android 数据库使用SqlCipher加密, 从代码来看, 是使用sqlcipher 1 版本,

private static final SQLiteCipherSpec qDP = 
new SQLiteCipherSpec().setPageSize(1024).setSQLCipherVersion(1);

使用诸如 DB Browser for SQLite , SQLiteStudio 等数据库管理软件都无法直接打开, 主要原因是连接参数不正确.

查看 SQLCipher 的源码发现设置 CipherVersion 为 1 时 , 会关闭 hmac, kdf_iter 为 4000.

public SQLiteCipherSpec setSQLCipherVersion(int version) {
    switch (version) {
        case 1: hmacEnabled = false; kdfIteration = 4000;  break;
        case 2: hmacEnabled = true;  kdfIteration = 4000;  break;
        case 3: hmacEnabled = true;  kdfIteration = 64000; break;
        default: throw new IllegalArgumentException("Unsupported SQLCipher version: " + version);
    }
    return this;
}

在尝试 SQLiteStudio 配合 Cipher configuration 来建立链接, 还是失败 配置如下.

PRAGMA kdf_iter = '4000';
PRAGMA cipher_use_hmac = OFF;
PRAGMA cipher = 'AES-256-CBC';
PRAGMA cipher_page_size = 1024;

查阅官方文档后发现有如下介绍:

PRAGMA cipher_compatibility: Force SQLCipher to operate with default settings consistent with that major version number for the current connection.

大概是说通过PRAGMA cipher_compatibility配置 , 设置这个版本号后, 会自动使用该版本默认的配置链接, 这样避免我们设置那些乱七八糟的配置,将下列配置粘贴到工具中的加密算法配置选项中

PRAGMA cipher_page_size = 1024;
PRAGMA cipher_compatibility = 1;

测试发现, OK~ 如下图.

MacBook使用SQLiteStudio链接微信加密数据库.jpg

附件:SQLiteStudio.dmg

转自:打开微信加密数据库

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容