我在用户登录时将密码存储到钥匙串。现在我正在处理更改密码页面。我想将密钥链密码与旧密码进行比较。如何检索钥匙串密码?
我正在使用 ASIHttpRequest 来验证用户。 ASIHttpRequest 将密码存储在钥匙串中。
[request setUseKeychainPersistence:YES];
[request setShouldPresentAuthenticationDialog:TRUE];
[request setShouldPresentCredentialsBeforeChallenge:TRUE];
有人可以帮助我如何从Keychain获取存储的密码?
答案 0 :(得分:1)
由于您使用的是ASIHTTPRequest
,因此您可以在ASIHTTPRequest.h
中使用其钥匙串界面:
// Return credentials from the keychain
+ (NSURLCredential *)savedCredentialsForHost:(NSString *)host port:(int)port protocol:(NSString *)protocol realm:(NSString *)realm;
在该文件中还有其他一些应该感兴趣的例程。搜索“钥匙串”。
答案 1 :(得分:0)
以下关于keychain的简单博客文章帮助我存储和检索iphone应用程序中的钥匙串值。正如Rob Napier发布ASIHttpRequest框架的答案,但我发现它有点复杂,我开始使用Apple KeychainItemWrapper类,它很容易实现。我将此标记为我的问题的答案。