Unable to encrypt the database


#1

Hi there,
Im new to SQLCipher. I followed all the instruction from link. But still I was unable to encrypt my database.
I have created a database using terminal commands :

sqlite3 nameOfDatabase.sql
create table tablename (attributes)
insert values

this database resides in the same folder where current xcode project is running.
I have inserted following code into the didFinishLaunchingWithOption: method

sqlite3 *db;
NSString *sqLiteDb = [[NSBundle mainBundle] pathForResource:@"sqlliteDemoFile.sql"
                                                     ofType:@"sqlite3"];
if(sqlite3_open(sqLiteDb.UTF8String, &db) == SQLITE_OK)
{
    const char* key = [@"StrongPassword" UTF8String];
    sqlite3_key(db, key, (int)strlen(key));
    if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
        NSLog(@"Password is correct, or a new database has been initialized");
    } else {
        NSLog(@"Incorrect password!");
    }
    sqlite3_close(db);
}

but it always goes into “else” part.

Can anyone help me regarding this ?