问题
I have been encrypting core-data fields using 'SecKeyWrapper' class provided in one of Apple's document. The SecKeyWrapper class is non-ARC. I'm wondering if this is still the best way to encrypt core-data fields or is there newer/better solution available ?
Thank you
回答1:
In iOS 5 and later Core Data by default uses NSFileProtection to protect persisted data.
For apps built for iOS 5.0 or later, persistent stores now store data by default in an encrypted format on disk. The default protection level prevents access to the data until after the user unlocks the device for the first time. You can change the protection level by assigning a custom value to the NSPersistentStoreFileProtectionKey key when configuring your persistent stores. For additional information about the data protection that are new in iOS 5.0, see “Data Protection Improvements.”
If you want to modify the default file protection behavior for your Core Data store, change the value for the key NSPersistentStoreFileProtectionKey to a different NSFileProtectionKey value in your store options dictionary.
Example:
NSDictionary *storeOptions = @{NSPersistentStoreFileProtectionKey : NSFileProtectionComplete};
if (![coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:[self storeURL] options:storeOptions error:&error]){
[self presentError:error];
}
来源:https://stackoverflow.com/questions/23201917/ios-core-data-encryption