0

I'm building an iPad app in where I need to implement a pin secure lock screen.

I have created a very simple hardcoded password 1234, see below:

- (IBAction)enterPassword
{
    NSString *passwordString = [NSString stringWithFormat:@"1234"];

    if ([passwordField.text isEqualToString:passwordString]) {
        //hide password field
        passwordField.hidden = YES;
        //show main application view
        [super viewDidLoad];


    }
    else {
        // Password is incorrect
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Incorrect Password" message:@"This password is incorrect." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
    }
}

Now, how can I implement an ability for user to change the password anytime they want to, so that they are not depended on the hardcoded password.

Also, when they are about to change the password they will be asked for the current old password in order to change it.

Please bare in mind that I'm a very new in iOS developing :(

Many thanks for your help.

angular_learner
  • 671
  • 2
  • 14
  • 31
  • What you should do is store a has of the pincode in the [`Keychain`](https://developer.apple.com/library/iOS/documentation/Security/Conceptual/keychainServConcepts/01introduction/introduction.html), thus making it more secure. – rckoenes Dec 01 '14 at 12:42
  • Thank you for your answer. I've read some forums and I know I should store it in the `Keychain` but I'm confused as how to do it. How hard it is to implement it? My text field is already `secure` – angular_learner Dec 01 '14 at 12:47
  • Well since I can't say how fast you pick up things, but it is not that hard. But I do suggest you use a wrapper like [SSKeyChain](https://github.com/soffes/sskeychain), this just makes it easier. – rckoenes Dec 01 '14 at 12:50
  • Many thanks, I will give it a go. The steps are: 1. Set initial password 2. Change old password 3. Read and compare passwords Please be patient with me :) Thanks again! – angular_learner Dec 01 '14 at 13:08
  • Ok, I thought I would be able to crack it and use your codes, but I'm not able to. I'm really new into iOS coding. Thank you for your help though. If you happen to know of any source code out there for my needs such as setting up the password, storing it, changing it, etc, to protect my app, that would be much appreciated. – angular_learner Dec 01 '14 at 23:16

0 Answers0