-
Notifications
You must be signed in to change notification settings - Fork 1
/
RSATool.h
70 lines (59 loc) · 1.22 KB
/
RSATool.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
//
// RSATool.h
// AFM
//
// Created by su-fun on 16/2/23.
// Copyright © 2016年 su-fun. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef enum {
KeyTypePublic = 0,
KeyTypePrivate
}KeyType;
@interface RSATool : NSObject
/**
* 导入密钥
*/
- (BOOL)importKeyWithType:(KeyType)type andPath:(NSString*)path;
- (BOOL)importKeyWithType:(KeyType)type andkeyString:(NSString *)keyString;
/**
* 验证签名 Sha1 + RSA
*/
- (BOOL)verifyString:(NSString *)string withSign:(NSString *)signString;
/**
* 验证签名 md5 + RSA
*/
- (BOOL)verifyMD5String:(NSString *)string withSign:(NSString *)signString;
/**
* Sha1+RSA签名
*
* @param string 要签名的内容
*
* @return 加签后的内容
*/
- (NSString *)signString:(NSString *)string;
/**
* MD5+RSA签名
*
* @param string 要签名的内容
*
* @return 加签后的内容
*/
- (NSString *)signMD5String:(NSString *)string;
/**
* 公钥加密
*
* @param content 要加密的明文
*
* @return 加密后的密文
*/
- (NSString *) encryptWithPublicKey:(NSString*)content;
/**
* 私钥解密
*
* @param content 密文
*
* @return 解密后的明文
*/
- (NSString *) decryptWithPrivatecKey:(NSString*)content;
@end