使用钥匙串
KeychainItemWrapper
C6E818F9-1E05-4DF1-83F5-93E84DEA5A9D.png
FD53CBDA-DE02-4B16-BBC8-F3906B40D4A1.png
#pragma mark - keychain读取
- (IBAction)read {
KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"Username"accessGroup:nil];
NSLog(@"pwd = %@,account = %@",[wrapper objectForKey:(__bridge id)kSecValueData],[wrapper objectForKey:(__bridge id)kSecAttrAccount]);
}
#pragma mark - keychain存储
- (void)save {
KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc]initWithIdentifier:@"Username"accessGroup:nil];
//保存帐号
[wrapper setObject:@"ly" forKey:(__bridge id)kSecAttrAccount];
//保存密码
[wrapper setObject:@"123456" forKey:(__bridge id)kSecValueData];
[wrapper setObject:@"aaaaaa" forKey:(__bridge id)kSecAttrTokenID];
}
网友评论