我认为问题出在第 2592 行。
在将 key 传递给 sqlite3_key(...) 时,不要将其视为字符串 不确定如何生成 key 但如果第一个字节设置为 '\0' 那么 strlen 返回 0 (如果您使用一些基于NSData 随机字节)
sqlite3_key定义:
SQLITE_API int SQLITE_STDCALL sqlite3_key(sqlite3 *db, const void *pKey, int nKey)
Run Code Online (Sandbox Code Playgroud)
它需要 nKey 字节,其中也允许“\0”
相反尝试:
NSData *passBytes = [g_sqlite_key dataUsingEncoding:NSUTF8StringEncoding];
int status = sqlite3_key(contactDB, passBytes.bytes, passBytes.length);
if (status != SQLITE_OK) {
// handle error and return
}
// continue...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
535 次 |
| 最近记录: |