在iPhone上存储用户名和密码的最佳做法是什么?

Jas*_*son 12 security iphone passwords objective-c

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

jan*_*mon 19

使用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;
Run Code Online (Sandbox Code Playgroud)

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

有关更多信息,请参阅他的博客


Nik*_*uhe 5

钥匙扣是你在找什么.

  • 该链接适用于Mac OS X钥匙串.这是iPhone版本的链接(它们略有不同):http://developer.apple.com/IPhone/library/documentation/Security/Conceptual/keychainServConcepts/02concepts/concepts.html (2认同)