Data Protection

* It looks no use for the toolkid to export the files(set protection by setting or code), file exported is unencrypted, even the device is lock.

* If passcode is lock, it can't copy out or view by toolkid.

* if passcode is lock ,we can't read the file after refresh toolkid,(both mode)

 

https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html

 

 

Enabling Data Protection (iOS Only)

Data protection adds a level of security to files stored on disk by your iOS app. Data protection uses the built-in encryption hardware present on specific devices to store files in an encrypted format on disk. Your app needs to be provisioned to use data protection.

To enable data protection

  1. In the Capabilities pane, if Data Protection isn’t enabled, select the switch in the Data Protection row.

  2. If a dialog appears asking whether Xcode should request a development certificate on your behalf, click Request.

The default level of protection is complete protection, in which files are encrypted and inaccessible when the device is locked. You can programmatically set the level of protection for files created by your app, as described in Protecting Data Using On-Disk Encryption in App Programming Guide for iOS.

 

- (IBAction)doWriteProtectedData:(id)sender{
    NSString *s = @"Hello2";
    NSError *err = NULL;
    NSString *sPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    sPath = [sPath stringByAppendingPathComponent:@"a.txt"];
    [s writeToFile:sPath atomically:YES encoding:NSUTF8StringEncoding error:&err];
    if(err){
        NSLog(@"err:%@",err.description);
    }
    
    err = NULL;
    NSDictionary *dicAtt = @{NSFileProtectionKey:NSFileProtectionComplete};
    [[NSFileManager defaultManager] setAttributes:dicAtt ofItemAtPath:sPath error:&err];
    if(err){
        NSLog(@"err:%@",err.description);
    }
    NSLog(@"Write to %@",sPath);
}

 

你可能感兴趣的:(Data)