0
我想使用NSFileManager加密我的iPad上的文件。這是代碼:使用NSFileManager加密文件
NSString* encryptedFilePath = [dirPath stringByAppendingPathComponent:@"encryptedDummyData.txt"];
[[NSFileManager defaultManager] createFileAtPath:encryptedFilePath
contents:[@"blah blah blah blah blah" dataUsingEncoding:NSUTF8StringEncoding]
attributes:[NSDictionary dictionaryWithObject:NSFileProtectionComplete
forKey:NSFileProtectionKey]];
該文件是在設備上生成的,但沒有加密。
我確保在「項目導航器/功能」下啓用了「數據保護」。
我也試過NSFileProjectionCompleteUnlessOpen
和NSFileProtectionCompleteUntilFirstUserAuthentication
沒有運氣。
我所做的唯一「進步」是,如果我在應用程序啓動後鎖定設備,那麼我將無法使用iExplorer訪問該文件。但是,當我解鎖設備的那一刻,我就可以打開文件,並且它未加密。
那麼,NSFileManager根本就加密了一個文件?或者只是在設備被鎖定時阻止用戶訪問文件?
如果它可以加密文件,那麼我錯過了什麼?
[Enable iOS On-Disk Encryption]的可能重複(http://stackoverflow.com/questions/15139305/enable-ios-on-disk-encryption) – staticVoidMan