I have been looking into this a lot and people only mention the iOS Keychain. However, I have one issue with storing passw开发者_开发问答ords with the keychain:
- For what I have read, the keychain behaves differently based on how you codesign your application. Since I don't codesign applications, I'm afraid I will find many stones while I try to use the Keychain without any signing profile.
So what other alternatives are to store passwords in iOS? I'm making two apps that really need to be pass-locked for the user.
In your example of a "Diary" application, there is no need to store the password. Just use symmetric-key algorithm to the encrypt and decrypt the data. Therefore only the user knows the password, not even your app.
To Save:
- Covert the "Diary" objects to NSData
- User types in password to encrypt NSData
- Write the encrypt NSData to file
To Load:
- Read the encrypt NSData from file
- User types in password to decrypt NSData
- Convert NSData to "Diary" objects
I have used Keychain in one of my apps and I used SFHFKeychainUtils classes which just make it easier to use Keychain. Refer to this blog:
http://gorgando.com/blog/tag/sfhfkeychainutils
Keychain is a secure way to store passwords since the storage values are encrypted.
精彩评论