izan
izan

Reputation: 737

Security in iPhone

My problem is : 1. I am developing an iPhone application i have proceded like this : the user authentication, with a user name and a password ( after a verification with web services), my question is how it is stored the username and the password in my application. are there secured or did i proced to implement a secure mechanism ?

thanks for your answer

Upvotes: 1

Views: 532

Answers (3)

Appz Venture
Appz Venture

Reputation: 939

Saving:

NSUserDefaults *userNamePrefs = [NSUserDefaults standardUserDefaults];
NSUserDefaults *passwordPrefs = [NSUserDefaults standardUserDefaults];

[userNamePrefs setObject:@"username" forKey:@"username"];
[passwordPrefs setObject:@"password" forKey:@"password"];

Retrieving

NSUserDefaults *userNamePrefs = [NSUserDefaults standardUserDefaults];
NSUserDefaults *passwordPrefs = [NSUserDefaults standardUserDefaults];

NSString *savedUsername = [prefs stringForKey:@"username"];
NSString *savedPassword = [prefs stringForKey:@"username"];

what else UITextbox User enter just match the string like

if ((usernameTextBox.Text isEqualToString(savedUsername)) && (passwordTextBox.Text isEqualToString(savedPassword)) ){
    // pass authentication
}
else{
  // show alert view fail authetication
}

Upvotes: -2

Pascalius
Pascalius

Reputation: 14669

I am using SFHFKeychainUtils. It uses apple's Security Framework. It's easy to use, to save a Username and Password:

[SFHFKeychainUtils storeUsername:userNameString andPassword:passwordString forServiceName:@"YourServiceName" updateExisting:TRUE error:&error]; 

and to retrieve the encrypted password for a Username

[SFHFKeychainUtils getPasswordForUsername:userNameString andServiceName:@"YourServiceName" error:&error];

Upvotes: 6

Michaël
Michaël

Reputation: 6734

Use the Keychain : Keychain iphone

Upvotes: 2

Related Questions