iOS随笔
1. iOS对资源文件加密--第三方框架RNCryptor的简单使用
前言:网上有对这个框架的介绍很多,这个框架更新很快,现在最新的是swift的语言,纯OC的最后一版是3.0.1版本,此次使用的正是此版本。
RNCryptor源码https://github.com/RNCryptor/RNCryptor。
基于RNCryptor有同学做了一个小工具,用来对资源文件先进行加密。(CXYRNCryptorTool)

接下来就是在代码中进行解密。


解密代码贴上
NSData *encryptedData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"AppStore-1024px" ofType:@"cxy"]];
NSError *error;
NSData *decryptedData = [RNDecryptor decryptData:encryptedData
withPassword:@"12345"
error:&error];
if (!error) {
NSLog(@"======dencrypt success!=====");
UIImage *image = [UIImage imageWithData:decryptedData];
imgView.image = image;
}else {
NSLog(@"======dencrypt failed!=====");
}
亲测有效

2.