存储账户密码
使用第三方SFHFKeychainUtils
引入头文件
#import <SFHFKeychainUtils.h>
/// 存储账户密码
+ (void)encryptionManagerKeychainUtilsStoreUsername:(NSString *)userName andPassword:(NSString *)password forServiceName:(NSString *)serviceName updateExisting:(BOOL)updateExisting {
[SFHFKeychainUtils storeUsername:userName andPassword:password forServiceName:serviceName updateExisting:YES error:nil];
}
根据用户名取出密码
/// 根据用户名取出密码
+ (NSString *)encryptionManagerKeychainUtilsGetPasswordForUsername:(NSString *)userName andServiceName:(NSString *)serviceName {
// NSString *passWordOld = [SFHFKeychainUtils getPasswordForUsernameOld:userName andServiceName:serviceName error:nil];
NSString *passWord = [SFHFKeychainUtils getPasswordForUsernameV2:userName andServiceName:serviceName error:nil];
return passWord;
}
删除用户
/// 删除用户
+ (void)encryptionManagerKeychainUtilsDeleteItemForUsername:(NSString *)userName andServiceName:(NSString *)serviceName withAccessible:(BOOL)accessible {
[SFHFKeychainUtils deleteItemForUsername:userName andServiceName:serviceName error:nil withAccessible:accessible];
}
网友评论