Storing passwords in iPhone applications

前端 未结 3 858
南笙
南笙 2020-12-12 23:02

I have a simple application, based of the \"Utility Application\" template. It retrieves a password-protected XML file (via NSXMLParser).

I want to allow the user to

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 23:35

    Aha, NSUserDefaults seems to work, and is simple to use, but isn't secure in the slightest:

    password is the IBOutlet for the UITextField.

    - (void)viewWillAppear:(BOOL)animated
    {
        NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
        NSString *pword = [prefs objectForKey:@"password"];
        password.text = uname;
    }
    
    - (void)viewWillDisappear:(BOOL)animated{
        NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
        [prefs setObject:password.text forKey:@"password"];
    }
    

    The password is stored in plain-text in a plist, so it would be quite easy for someone else to access.. but this is useful for storing non-sensitive settings.

    I ended up using this to store the username field, and stored the password using the SFHFKeychainUtils keychain code from August's answer.

提交回复
热议问题