#import "ViewController.h"
#import "RSAEncryptor.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString * str=@"hello123很好*";
//创建RSA对象
RSAEncryptor *rsa = [[RSAEncryptor alloc] init];
//获取公钥路径
NSString *publicKeyPath = [[NSBundle mainBundle] pathForResource:@"public_key" ofType:@"der"];;
[rsa loadPublicKeyFromFile:publicKeyPath];
//开始加密
NSString *encryptedString = [rsa rsaEncryptString:str];
NSLog(@"加密后的结果: %@", encryptedString);
//获取私钥路径
[rsa loadPrivateKeyFromFile:[[NSBundle mainBundle] pathForResource:@"private_key" ofType:@"p12"] password:@"123456"];
//开始解密
NSString *decryptedString = [rsa rsaDecryptString:encryptedString];
NSLog(@"解密结果: %@", decryptedString);
}