What is the best way to save data (e.g. passwords) which the user can't manipulate or see? NSUserDefaults
are getting saved in a file on the Mac which the user can manipulate and see. How about Core Data
? Is this also saved in a file or is there a way that the user can see the Core Data
?
Asked
Active
Viewed 147 times
3

Megaetron
- 1,154
- 2
- 15
- 29
-
2use the keychain - https://developer.apple.com/library/mac/documentation/Security/Conceptual/keychainServConcepts/iPhoneTasks/iPhoneTasks.html – pds Jul 20 '16 at 23:02
-
1Yes, core-data files can be accessed easily. The best solution is to encrypt the data you need hidden. – john elemans Jul 20 '16 at 23:02
-
there's a great wrapper for the keychain https://cocoapods.org/pods/SSKeychain – markedwardmurray Jul 21 '16 at 07:01
3 Answers
12
NSUserDefaults definitely shouldn't be used to store passwords because it is stored in plain text. Core data can be encrypted, but it isn't by default. It stores all of its data in a SQLite database which is really easy to read. Passwords should be stored in the system Keychain. The keychain can be accessed with the Security Framework.
There are several libraries out there that make using the keychain much easier, eg: Locksmith or Valet.

esthepiking
- 1,647
- 1
- 16
- 27