Keychain VS UserDefaults
In this story, we will discuss why we should not UserDefaults to save email, tokens , passwords and other credentials.
Firstly we will try to know real definition or use of UserDefaults and keychain.
A keychain is an encrypted container that holds passwords for multiple applications and secure services. Apple Inc. uses keychains as password management system in Mac OS and iOS.
UserDefaults Provides a way for application behavior Customization based on user preferences. Belongs to the Foundation framework for Cocoa and Cocoa Touch.
UserDefaults are stored in plain text within the bundlename.plist file on a device. Everyone with access to a device can open or copy the file and read the information without encryption. so its very easy to intruder to get your confidential information whereas, KeyChain
on the other hand, is encrypted and persists independently of your app. So for storing sensitive data such as email, tokens , passwords and other credentials you should absolutely use KeyChain
.
Thanks!! Hope this will help you to learn. Please take a minute to review.