-(void)readDataBase{
NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]stringByAppendingPathComponent: @“encrypted.db”];
NSLog(@“the DataBasePath is ::%@”,databasePath);
sqlite3 *db;
if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
const char* key = [@"test123" UTF8String];
char *error = nil;
sqlite3_key(db, key, (int)strlen(key));
if (sqlite3_exec(db,"SELECT count(*) FROM sqlite_master;", NULL, NULL, &error) == SQLITE_OK) {
// password is correct, or, database has been initialized
NSLog(@"correct password");
} else {
// incorrect password!
NSLog(@"incorrect password");
NSLog(@"%s",error);
}
sqlite3_close(db);
}
}