Skip to content

增加对更加加密算法的支持 #1

@Mq-b

Description

@Mq-b

目前的 cpp-sqlitelib 是基于原仓库 cpp-sqlitelib修改的。

原仓库属于一个纯头文件库,封装的是标准 sqlite3,而标准 sqlite3 是默认不支持加密数据库的。

我们将仓库fork后,将原本仓库的 sqlite3 源码删除,修改 cmake 以及部分源码,让其查找 sqlite3mc,以支持加密数据库。

然而截止目前,仅仅是添加了一个 setPassword 函数:

https://github.com/Mq-b/cpp-sqlitelib/blob/ff9896c/sqlitelib.h#L287-L297

void setPassword(const std::string& passworld) const {
    int rc = sqlite3_key(db_, passworld.c_str(), static_cast<int>(passworld.size()));
    if (rc != SQLITE_OK) {
        throw std::runtime_error("设置密码错误");
    }

    rc = sqlite3_exec(db_, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr);
    if (rc != SQLITE_OK) {
        throw std::runtime_error("密码验证错误");
    }
}

直接使用了 sqlite3_key 这意味着选择了默认的加密算法为 ChaCha20-Poly1305

然而 sqlite3mc 总共支持 6 种加密算法:

文档:https://utelle.github.io/SQLite3MultipleCiphers/

我们需要补齐对剩下加密算法的支持,以及添加更多的测试用例,修改 cmake 和 README。

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions