-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeychainTool.h
82 lines (58 loc) · 2.44 KB
/
KeychainTool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// KeychainTool.h
// RuntimeTest
//
// Created by user on 2020/4/15.
// Copyright © 2020 zilong. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#define BRIDGE(type, object) (__bridge type)object
typedef NS_ENUM(NSInteger, KeyChainExecuteStatus) {
KeyChainExecuteStatusFailure = 0,// 操作失败
KeyChainExecuteStatusSuccess// 操作成功
};
@interface KeychainToolStatus : NSObject
/// 执行状态
@property (nonatomic, assign) KeyChainExecuteStatus executeStatus;
/// 数据
@property (nonatomic, strong) NSData *executeData;
@end
@interface KeychainTool : NSObject
+ (KeychainTool *)sharedKeychain;
//=============================== 快捷存储 ============================
/// 增加Keychain
/// @param key 标识(主标识)
/// @param serviceKey 标识(副标识)
/// @param value 插入的值 须转成NSData类型
- (BOOL)addKeychainWithKey:(NSString *)key serviceKey:(NSString *)serviceKey value:(NSData *)value;
/// 查询
/// @param key 标识(主标识)
/// @param serviceKey 标识(副标识)
- (KeychainToolStatus *)queryKeychainWithKey:(NSString *)key serviceKey:(NSString *)serviceKey;
/// 更新
/// @param key 标识(主标识)
/// @param serviceKey 标识(副标识)
/// @param value 更新的值 插入的值 须转成NSData类型
- (BOOL)updateKeychainWithKey:(NSString *)key serviceKey:(NSString *)serviceKey changeValue:(NSData *)value;
/// 删除
/// @param key 标识(主标识)
/// @param serviceKey 标识(副标识)
- (BOOL)deleteKeychainWithKey:(NSString *)key serviceKey:(NSString *)serviceKey;
//============================== 自定义存储 ===================================
/// 添加
/// @param cfDictionary 自定义Dictionary 包含类型和标识等
/// @param dataValue 插入的数据
- (BOOL)addKeychainWithKeyDictionary:(NSDictionary *)cfDictionary dataValue:(NSData *)dataValue;
/// 查询
/// @param cfDictionary 自定义Dictionary 包含类型和标识等
- (KeychainToolStatus *)queryKeychainWithKeyDictionary:(NSDictionary *)cfDictionary;
/// 更新
/// @param cfDictionary 自定义Dictionary 包含类型和标识等
/// @param updateData 更新的数据
- (BOOL)updateKeychainWithKeyDictionary:(NSDictionary *)cfDictionary updateData:(NSData *)updateData;
/// 删除
/// @param cfDictionary 自定义Dictionary 包含类型和标识等
- (BOOL)deleteKeychainWithKeyDictionary:(NSDictionary *)cfDictionary;
@end
NS_ASSUME_NONNULL_END