#import "ViewController.h"
#import "CryptorTools.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
CryptorTools *tool = [[CryptorTools alloc]init];
NSString *privateKey = [[NSBundle mainBundle]pathForResource:@"p.p12" ofType:nil];
NSString *publicKey = [[NSBundle mainBundle]pathForResource:@"rsacert.der" ofType:nil];
// 加载私钥
[tool loadPrivateKey:privateKey password:@"123456"];
// 加载公钥
[tool loadPublicKeyWithFilePath:publicKey];
// 加密
NSString *result = [tool RSAEncryptString:@"itcast"];
NSLog(@"rsa加密结果 %@",result);
// 解密
NSString *result1 = [tool RSADecryptString:result];
NSLog(@"rsa解密结果 %@",result1);
}
@end
网络:RSA 加密
最新推荐文章于 2023-12-13 21:33:38 发布