iOS Core Data encryption [closed]

折月煮酒 提交于 2019-11-27 02:48:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!