Kikeychain safely save user name and password

Source: Internet
Author: User

During the development of IOS applications, we often store some of the more important information. If it involves the user system of the APP, we need to consider the function of automatic login, if the user's username and password stored in the Nsuserdefault is very insecure. First, this information is stored in plaintext; second, you can obtain information from the Nsuserdefault by some tools. Easy to cause leakage of user's account information.
For security reasons, Apple has provided us with a tool called KeyChain, and the information stored in it is not absolutely secure, but it is much more secure than nsuserdefault or some other information stored in the APP sandbox. First, KeyChain storage location is located in/private/var/keychains/..., if we want to directly access the information inside, we must first jailbreak before access, and secondly, the key information of KeyChain is encrypted processing, So even after the acquisition of the need to do the hack work.
There's a lot of access to KeyChain on the Web, and Apple offers a Demo. However, the feeling is not practical, the operation is relatively troublesome. So I decided to re-encapsulate it, so we have this kikeychain component.

#import "ViewController.h"

#import "KIKeyChain.h"

@interface viewcontroller ()

@end

@implementation Viewcontroller

-(void) viewdidload {

[Super viewdidload];

kikeychain *key = [kikeychain keychainwithidentifier:@ "Default_user"];

[Key SetValue:@ "user1" forkey:@ "username"];

[Key SetValue:@ "Password1" forkey:@ "password"];

[Key write];

}

-(void) didreceivememorywarning {

[Super didreceivememorywarning];

//Dispose of any resources, can be recreated.

}

-(void) Viewdidappear: (BOOL) animated {

[Super viewdidappear: animated];

kikeychain *key = [kikeychain keychainwithidentifier:@ "Default_user"];

NSLog(@ "%@==%@", [key Valueforkey:@ "username"], [key Valueforkey:@ " Password "]);

}

@end

Kikeychain safely save user name and password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.