I need to secure my data in Documents Directory so I have used Apple Data Protection API. Apple Asset
- I Enabled Data Protection in Settings App. Settings->General->Passcode Lock On
I Write the file Using the NSDataProtectionKey
[data writeToFile:imagePath options:NSDataWritingFileProtectionComplete error:nil];
File is written successfully
I get the file attributes
[[NSFileManager defaultManager] attributesOfItemAtPath:fullPath error:NULL];
It returns this the attributes like this as you can see the NSFileProtectionKey is NSFileProtectionComplete
NSFileCreationDate = "2013-01-22 06:10:48 +0000"; NSFileExtensionHidden = 0; NSFileGroupOwnerAccountID = 501; NSFileGroupOwnerAccountName = mobile; NSFileModificationDate = "2013-01-22 06:10:48 +0000"; NSFileOwnerAccountID = 501; NSFileOwnerAccountName = mobile; NSFilePosixPermissions = 420; NSFileProtectionKey = NSFileProtectionComplete; NSFileReferenceCount = 1; NSFileSize = 8964; NSFileSystemFileNumber = 335997; NSFileSystemNumber = 16777218; NSFileType = NSFileTypeRegular;
I am sure that I have written the file successfully and I read that file successfully. But when I open this device in iExplorer(A external iOS device reader app for mac) it shows me the file written without encrypted.
Without encrypted means I write a image file. But I am able to view that image(in documents Directory) in iExplorer. But my purpose is to encrypt that. Because I dont want users to see those files. I am aware other encryption AES Algorithms. But want to know why Data Protection API didn't work.
Note: I Use iPad2 iOS 6.0.1 and Logs recorded in device