What is the best practice to store username and password on the iPhone?(在 iPhone 上存储用户名和密码的最佳做法是什么?)
问题描述
是否有在 iPhone 上存储用户名和密码的最佳做法?我正在寻找明显安全但也会在应用更新之间保留信息的东西.
使用 Apple Keychain.
+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;+ (void) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error;
<块引用>
第一种方法允许你请求与某个关联的密码特定的现有用户名服务名称(我刚刚使用我的应用程序的名称作为服务名称).这第二个允许您存储一个用户名/密码/服务名称组合,并允许您指定是否不是合适的钥匙串项目应使用提供的更新如果找到现有的密码匹配用户名和服务名称对.每个的最后一个参数是对 NSError 对象的引用这将包含较低级别的错误出现问题时的信息(如果不是,则为 nil).
有关更多信息,请参阅他的博客
Is there a best practice way to store username and password on the iPhone? I am looking for something that is obviously secure but will also keep the info between app updates.
Use the Apple Keychain.
+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;
+ (void) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error;
The first method allows you to request the password associated with an existing username for a particular service name (I’ve just been using the name of my app as a service name). The second allows you to store a username/password/service name combo, and allows you to specify whether or not the appropriate keychain item should be updated with the provided password if an existing one is found that matches the username and service name pair. The last parameter of each is a reference to an NSError object which will contain lower level error information if something goes wrong (and be nil if it does not).
For more information see his blog
这篇关于在 iPhone 上存储用户名和密码的最佳做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 iPhone 上存储用户名和密码的最佳做法是什么?


- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01