我正在尝试按照本教程:http://sqlcipher.net/ios-tutorial/
我创建了一个名为“sqlcipher.db”的数据库,然后重新创建了这个
执行此代码时:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
stringByAppendingPathComponent: @"encrypted.db"];
sqlite3 *db;
if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
const char* key = [@"secret" UTF8String];
int sqlite3_key(sqlite3 *db, const void *pKey, int nKey);
sqlite3_key(db, key, strlen(key));
if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM t1;", NULL, NULL, NULL) == SQLITE_OK) {
// password is correct, or, database has been initialized
NSLog(@"Hello 1");
} else {
// incorrect password!
NSLog(@"Hello 2");
}
sqlite3_close(db);
} else {
NSLog(@"Hello 3");
}
}
总是超出“你好2”。
当我尝试重现这里描述的加密数据库的步骤时http://zetetic.net/blog/2009/12/29/how-to-encrypt-a-plaintext-sqlite-database-to-use-sqlcipher.html#disqus_thread我无法加密它,我相信这是因为我使用的是sqlite3 mac命令。
所以我在评论中看到S Lombardo说我必须编译命令行sqlcipher可执行文件,但链接不起作用。
我应该如何加密我的数据库以与SQLcipher一起使用?
有没有人在iOS中使用sqlicipher成功?
答案 0 :(得分:1)
一小时后谷歌搜索我发现如何为OSX编译sqlcipher命令行:
我希望这可以帮助某人。
https://groups.google.com/forum/#!msg/sqlcipher/bd1R13RpZHQ/SEPK8YrRt1gJ