How To Encrypt Using Encryptedcoredata With Swift?
I've been having some trouble figuring out how to encrypt my sqlite database. I'm using core data and this following project: https://cocoapods.org/?q=EncryptedCoreData What I can'
Solution 1:
I translated the Objective-C to Swift and it worked, I just added this lines
let container = NSPersistentContainer(name: "DbModel")
// Begin of my code
let cOpts : NSDictionary = [
EncryptedStore.optionPassphraseKey() : "123deOliveira4", //your Key
EncryptedStore.optionFileManager() : EncryptedStoreFileManager.default()
]
let desc = try! EncryptedStore.makeDescription(options: cOpts as! [AnyHashable : Any], configuration: nil)
container.persistentStoreDescriptions = [desc]
//End
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
Post a Comment for "How To Encrypt Using Encryptedcoredata With Swift?"