核心数据数据加密 [英] Core Data data encryption
问题描述
据我了解,要为Core Data启用数据加密,设备需要启用/打开密码,并将此密钥包含在 addPersistentStoreWithType
:方法的可选字典中.我确实为我的设备和项目中的以下代码启用了密码:
From what I understand, to enable data encryption for Core Data the device needed to enable/turn on Passcode and included this key in the optional dictionary for the addPersistentStoreWithType
: method. I did enable Passcode for my device and this code in the project:
NSPersistentStore *store = [self.managedObjectContext.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:self.storeURL
options:@{ NSPersistentStoreUbiquitousContentNameKey : @"iCloudStore",
NSPersistentStoreFileProtectionKey : NSFileProtectionComplete}
error:&error];
但是,当我使用名为Liya(从Mac应用商店下载)的软件直接打开sqlite数据文件时,我能够在sqlite数据库中查看数据.我使用iTunes文件共享将sqlite数据库文件从设备保存到了Mac.
But when I opened the sqlite data file directly using a software called Liya (downloaded from Mac app store), I was able to see the data in the sqlite database. I saved the sqlite database file from my device to my Mac using iTunes filesharing.
由于数据已加密,我是否应该完全无法使用Liya之类的工具直接查看数据?
Since data were encrypted, should I not be able to see data directly using tools such as Liya at all?
推荐答案
加密仅在设备上有效.通过iTunes或Xcode从设备上复制的文件始终会被解密.将设备与iTunes配对时,它会从计算机上的手机创建所有加密密钥的副本.这是必需的,以便iTunes可以在手机锁定时创建备份并进行同步.
The encryption only works on the device. Files you copy off the device via iTunes or Xcode always get decrypted. When you pair your device with iTunes it creates a copy of all the encryption keys from the phone on your computer. That is necessary so iTunes can create backups and sync while your phone is locked.
这篇关于核心数据数据加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!