在iPhone上存储用户名和密码的最佳做法是什么? [英] What is the best practice to store username and password on the iPhone?

查看:179
本文介绍了在iPhone上存储用户名和密码的最佳做法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有在iPhone上存储用户名和密码的最佳实践方法?我正在寻找一些明显安全的东西,但也会保留应用更新之间的信息。

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.

推荐答案

使用Apple Keychain。

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;




第一种方法允许您请求
相关的密码使用
特定
服务名称的现有用户名(我刚刚使用我的应用程序的
名称作为服务名称)。
秒允许您存储
用户名/密码/服务名称组合,
并允许您指定是否或
不是相应的钥匙串项
应该更新使用提供的
密码(如果找到现有的密码)
与用户名和服务
名称对匹配。每个
的最后一个参数是对NSError对象
的引用,如果出现问题,它将包含较低级别的错误
信息
(如果没有则为nil)。

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上存储用户名和密码的最佳做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆