gpt4 book ai didi

ios - sqlcipher 在 iOS 10 中停止工作

转载 作者:搜寻专家 更新时间:2023-10-30 20:14:07 25 4
gpt4 key购买 nike

我在我的 iOS 项目中使用 Sqlite (sqlcipher) 作为数据库。在 iOS 9 中,一切都完美运行。现在我更新了新的 Xcode。但是数据库加密现在不起作用。

sqlite3 *db1;
if (sqlite3_open([[self.databaseURL path] UTF8String], &db1) == SQLITE_OK) {
const char* key = [g_sqlite_key UTF8String];
AZLog(@"%s",key);
sqlite3_key(db1, key, (int)strlen(key));
if (sqlite3_exec(db1, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
AZLog(@"Password is correct, or a new database has been initialized");
} else {
AZLog(@"Incorrect password!");
}
sqlite3_close(db1);
}

谁能帮帮我?

提前致谢

最佳答案

使用sqlcipher加密数据库时必须提供readwrite和open-create权限。

sqlite3 *db1;
if (sqlite3_open_v2([[self.databaseURL path] UTF8String], &db1, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) == SQLITE_OK) {
const char* key = [g_sqlite_key UTF8String];
AZLog(@"%s",key);
sqlite3_key(db1, key, (int)strlen(key));
if (sqlite3_exec(db1, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
AZLog(@"Password is correct, or a new database has been initialized");
} else {
AZLog(@"Incorrect password!");
}
sqlite3_close(db1);
}

关于ios - sqlcipher 在 iOS 10 中停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39990699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com