I am working on an iOS app which uses the Keychain, Security.framework and Apple's KeychainWrapper class to securely store the users password in my app.
The app allows users to make accounts. When a user makes an account, the app needs to send the encrypted version of the users password to my server (POST request).
This all works, but the problem I am having is that I can store data securely and retrieve it, but I don't know how to go about retrieving the encrypted version of my data.
In other words, lets say the user makes an account and they set their password to "hello". I then set the app to securely store that in the keychain.
So then iOS encrypts it and stores it in the keychain. For the sake of this question lets pretend the encrypted version is "h235llo".
Now when I want to send the password to my server, I DONT want to send "hello". I want to send "h235llo" (the encrypted string). How do I get access to the encrypted string?
Here is the code I am using to access the Keychain:
To securely store username/password to the keychain, I am doing this:
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"UserLoginData" accessGroup:nil];
[keychain setObject:_username.text forKey:(__bridge id)kSecAttrAccount];
[keychain setObject:_password.text forKey:(__bridge id)kSecValueData];
And to securely retrieve the username/password from the keychain I am doing this:
NSString *secureUser = [keychain objectForKey:(__bridge id)kSecAttrAccount];
NSString *securePass = [keychain objectForKey:(__bridge id)kSecValueData];
Any help on this matter would be much appreciated.
Thanks for your time, Dan.