In an iPhone app project I’ve been working on recently, we needed to store sensitive information in a Core Data database. Without going into too much detail, let’s say we wanted to fill an Account table with usernames and passwords, but, of course, we couldn’t just store the passwords in clear text in the database.
Researching about best practices to do this, I came across this little great article. According to the author, “the keychain is about the only place that an iPhone application can safely store data”, referring to the Keychain Services in iOS. The author also provides some useful methods to make accessing the Keychain less of a pain.
Based on that article, I’ll show you an example of how to combine both Core Data with the Keychain to store passwords securely and seamlessly in NSManagedObject classes.