Hi,
Nowadays I try to encrypt a database with metadata below:
override init() { super.init() path = BackUpMigrationHelper.migrateToBackupDatabaseIfNeeded() dbQueue = FMDatabaseQueue(path: path) dbQueue.inDatabase { database in // executeStatements method of FMDB uses sqlite3_exec let isPasswordSet = database.setKey("password") database.executeStatements("PRAGMA cipher_memory_security = OFF") database.executeStatements("PRAGMA kdf_iter = 64000") database.executeStatements("PRAGMA cipher_page_size = 1024") database.executeStatements("PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1") database.executeStatements("PRAGMA cipher_hmac_algorithm = HMAC_SHA1") debugPrint("password set : \(isPasswordSet)") } try? createTableIfNeeded(DatabaseMessageTable.current) } public func createTableIfNeeded(_ table: DatabaseMessageTable) throws { var error: Error? dbQueue.inTransaction { (database, _) in do { try database.executeUpdate( "CREATE TABLE IF NOT EXISTS \(table.name)(\(id) INTEGER PRIMARY KEY AUTOINCREMENT,\(txnid) TEXT,\(rawxml) TEXT);", values: []) Logger.logVerbose("DatabaseHelper. createOrOpenDB. SUCCESS") } catch let dbError { Logger.logError("DatabaseHelper. createOrOpenDB. FAILURE. \(dbError.localizedDescription)") error = dbError } } if let error = error { throw error } }
when I run the code above, I see that the database created on the path, then I try to open it in SQL DB Browser with metadata, however it always fails.
Additionally SQLCipher version is 4.4.2 and FMBD version is 2.7.5.
On the other hand, I realized that ‘Google-Mobile-Ads-SDK’ pod (includes “sqlite3”) in another target non related with SQLCipher inserted target. Does it make fail? For example:
target 'TestProject' do use_frameworks! inherit! :search_paths pod 'Google-Mobile-Ads-SDK' end
target 'FMDBTarget' do use_frameworks! inherit! :search_paths pod 'FMDB' pod 'FMDB/standalone' pod 'FMDB/SQLCipher' end