0
컴파일 에러를 얻을 암호화하지 않습니다,하지만 내 데이터베이스를 암호화하지 않습니다SqlCipher 내가 그나마
const char* key = [@"BIGSecret" UTF8String];
int err = sqlite3_key(database, key, strlen(key));
if (sqlite3_exec(database, (const char*) "SELECT count(*) FROM animals;", NULL, NULL, NULL) == SQLITE_OK) {
// database has been initialized
}
내가 사이트 http://sqlcipher.net/documentation/ios를 참조하고 이미 AnimalDatabase.sql 데이터베이스가 SQLiteTutorial 예를 사용하고 있습니다.
는 또한 기존 데이터베이스에 암호화를 못해 일을 알게 된, 그래서 난 아래의 코드를 시도 : - (void)encryptDB
{
NSLog (@"Start");
sqlite3 *DB = [self getNewDBConnection];
sqlite3_exec(DB, "ATTACH DATABASE AnimalDatabase.sql AS encrypted KEY 1234;", NULL, NULL, NULL);
sqlite3_exec(DB, "CREATE TABLE encrypted.Account(id,Name,Desc,Image);", NULL, NULL, NULL);
sqlite3_exec(DB, "INSERT INTO encrypted.Account SELECT * FROM animals;", NULL, NULL, NULL);
sqlite3_exec(DB, "DETACH DATABASE encrypted;", NULL, NULL, NULL);
NSLog (@"End");
}
- (sqlite3 *)getNewDBConnection{
if (sqlite3_open([databasePath UTF8String], &newDBconnection) == SQLITE_OK) { // opening AnimalDatabase.sql
NSLog(@"Database Successfully Opened :)");
} else {
NSLog(@"Error in opening database :(");
}
return newDBconnection;
}
하지만 여전히 성공. 누구든지 도와 줄 수 있습니까?