Security Issues on iPhone
I'm doing an app that needs to connect with a login form to the web. I'd like 开发者_如何学编程to store these informations, my questions are:
A) Is it safe to store these data into NSUserDefaults?
B) Should I use CoreData?
C) Is there safer method?
CoreData is not secure unless you encrypt the data within it.
KeyChainAccess is apparently secure. There is some useful code to access it here:
https://github.com/ldandersen/scifihifi-iphone
You just need the two files under the the security folder.
You can then use these helper calls:
+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;
+ (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error;
+ (BOOL) deleteItemForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;
NSUserDefaults is not Safe for storing login details
Core Data is very ueful for persistent storage and also secure. Core Data Tutorial Here
You can also use KeyChainAccess which is also secure.Sample code Here
精彩评论