SQLCipher“sqlite3_key”加密数据库无法使用SqliteManger工具打开

时间:2013-12-24 06:12:06

标签: sqlite sqlcipher

这是我创建新加密数据库的代码

sqlite3 *db;

if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
    const char* key = "sssri";    //the key to encrypt the database
    sqlite3_key(db, key, strlen(key));    //using the SQLCipher to encrypt database
    if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
        NSLog(@"password is correct, or, database has been initialized");  //this step is also successful
        if(sqlite3_exec(db, (const char*)"create Table student (name char(4) primary key,class varchar(50) not null)", NULL, NULL, NULL)== SQLITE_OK)
        {
            NSLog(@"create a table")    //create a table if not the database is empty,and create successfully
            ;            }

    } else {
        NSLog(@"incorrect password!");
  }

    sqlite3_close(db);

但是当我尝试使用SqliteManger工具打开我的app文档中的sqlite数据库时,我输入了" sssri"键,数据库无法正确打开。

为什么?一些帮助将不胜感激!

2 个答案:

答案 0 :(得分:2)

SQLite Manager工具不支持SQLCipher。如果您想在代码库之外与SQLCipher数据库进行交互,请考虑使用SQLCipher command line shell

答案 1 :(得分:0)

尝试使用版本4.3.0(或更高版本):http://www.sqlabs.com/news/sqlitemanager/

相关问题