3

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?

Megaetron
  • 1,154
  • 2
  • 15
  • 29

3 Answers3

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
1

In addition to @esthepiking's suggestion to use Keychain, be aware that implementing your own encryption to store passwords might create obligations for you to provide more paperwork under the App Store's "Export Compliance" requirements. See this post.

Community
  • 1
  • 1
jp2g
  • 682
  • 4
  • 8
0

You can see this link to get the example to use ios Keychain Services to store and retrieve user name and password securely

Saraswati
  • 1,516
  • 1
  • 14
  • 21