Is there anyway one can override NSPersistentDocument to encrypt and require a password to open the file? In other words, is it possible to encrypt a document as a whole with a user provided password? I've looked into solutions and it seems the only way is to actually encrypt the CoreData data itself independently, however that would make it impossible to use a NSPredicate to filter a NSFetchRequest since the data would be encrypted. An alternative would be using Realm which has an encryption key, but that only encrypts the Realm data, leaving all other data in the document unencrypted.
问问题
60 次
2 回答
1
您可以加密 CoreData 对象,并通过在读取时创建瞬态(仅在内存中)明文字段,您可以使用 NSPredicate 过滤这些明文字段上的 NSFetchRequest。有关加密/解密代码的示例,请参见此处:https ://github.com/michaelrourke/EncryptedCoreData
于 2018-08-28T07:29:23.293 回答
0
查看文档NSPersistentStore
及其两个抽象子类NSAtomicStore
和NSIncrementalStore
. 如果您创建其中之一的自定义子类,则可以自定义 Core Data 写入的后端。
于 2018-05-12T19:09:56.897 回答