There is no built-in way to do this right now. Are you talking about Core Data's NSPersistentStoreFileProtectionKey option?
In the meantime, you can duplicate the code for SQLiteStore and implement your own LocalStorage that adds NSPersistentStoreFileProtectionKey option to the options dictionary:
Note that this just uses iOS's Data Protection API and the file is only encrypted when the user's device is passcode-locked.
Otherwise, if you are looking for a way to fully encrypt the database you would need to look for a separate framework, wrap it in an NSIncrementalStore implementation (I found a very old library here), and then implement CoreStore's LocalStorage protocol. Needless to say, this seems like a lot of work.
@JohnEstropia commented on GitHub (Jan 19, 2017):
There is no built-in way to do this right now. Are you talking about Core Data's `NSPersistentStoreFileProtectionKey` option?
In the meantime, you can duplicate the code for `SQLiteStore` and implement your own `LocalStorage` that adds `NSPersistentStoreFileProtectionKey` option to the options dictionary:
```swift
class EncryptedSQLiteStore: LocalStorage, DefaultInitializableStore {
// ...
public let storeOptions: [AnyHashable: Any]? = [
NSSQLitePragmasOption: ["journal_mode": "WAL"],
NSPersistentStoreFileProtectionKey: NSFileProtectionComplete // add this
]
// ...
}
```
Note that this just uses iOS's Data Protection API and the file is only encrypted when the user's device is passcode-locked.
Otherwise, if you are looking for a way to fully encrypt the database you would need to look for a separate framework, wrap it in an `NSIncrementalStore` implementation (I found [a very old library here](https://github.com/project-imas/encrypted-core-data/)), and then implement CoreStore's `LocalStorage` protocol. Needless to say, this seems like a lot of work.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @yaochenfeng on GitHub (Jan 18, 2017).
how to encrypted sql file by use corestore
@JohnEstropia commented on GitHub (Jan 19, 2017):
There is no built-in way to do this right now. Are you talking about Core Data's
NSPersistentStoreFileProtectionKeyoption?In the meantime, you can duplicate the code for
SQLiteStoreand implement your ownLocalStoragethat addsNSPersistentStoreFileProtectionKeyoption to the options dictionary:Note that this just uses iOS's Data Protection API and the file is only encrypted when the user's device is passcode-locked.
Otherwise, if you are looking for a way to fully encrypt the database you would need to look for a separate framework, wrap it in an
NSIncrementalStoreimplementation (I found a very old library here), and then implement CoreStore'sLocalStorageprotocol. Needless to say, this seems like a lot of work.