-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Xcode 10.1 currently being used
(but couldn't get things working on 10.2 either)
Test iPhones: (both fail)
iPhone 5s (iOS 10.3.3)
iPhone 6 using simulator (iOS 12.1)
From pod install ..
Using SQLCipher (4.1.0)
Using SQLite.swift (0.11.5)
database.key(key) fails
error='file is not a database (code: 26)'
My code - unchanged for over a year ..
do {
try database = Connection(path, readonly: true)
try database!.key(key) // failing line - exec goes to Cipher.swift below ..
Cipher.swift ..
//key is correct - defined as String
//db is "main"
public func key(_ key: String, db: String = "main") throws {
try _key_v2(db: db, keyPointer: key, keySize: key.utf8.count) // goes to function below ..
}
: :
// MARK: - private
private func _key_v2(db: String, keyPointer: UnsafePointer<UInt8>, keySize: Int) throws {
try check(sqlite3_key_v2(handle, db, keyPointer, Int32(keySize)))
try cipher_key_check() // goes to function below ..
}
: :
// When opening an existing database, sqlite3_key_v2 will not immediately throw an error if
// the key provided is incorrect. To test that the database can be successfully opened with the
// provided key, it is necessary to perform some operation on the database
// (i.e. read from it).
private func cipher_key_check() throws {
try scalar("SELECT count(*) FROM sqlite_master;") // this throws error
}