【问题标题】:SQLcipher how to create cypted database?SQLcipher如何创建密码数据库?
【发布时间】:2012-05-14 17:09:42
【问题描述】:

我正在尝试学习本教程: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");
    }
}

它总是输出“Hello 2”。

当我尝试重现此处描述的创建加密数据库的步骤http://zetetic.net/blog/2009/12/29/how-to-encrypt-a-plaintext-sqlite-database-to-use-sqlcipher.html#disqus_thread 时,我无法对其进行加密,我相信这是因为我使用的是 sqlite3 mac 命令。

所以我在 cmets 中看到 S Lombardo 说我必须编译一个命令行 sqlcipher 可执行文件,但链接不起作用。

我应该如何加密我的数据库以将其与 SQLcipher 一起使用?

有人在 iOS 中使用 sqlicipher 成功了吗?

【问题讨论】:

    标签: ios ios5 sqlcipher


    【解决方案1】:

    谷歌搜索一小时后,我找到了如何为 OSX 编译 sqlcipher 命令行:

    我希望这可以帮助某人。

    https://groups.google.com/forum/#!msg/sqlcipher/bd1R13RpZHQ/SEPK8YrRt1gJ

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-05
    • 2014-10-03
    相关资源
    最近更新 更多