1. iOS對資源文件加密--第三方框架RNCryptor的簡單使用
前言:網(wǎng)上有對這個框架的介紹很多安拟,這個框架更新很快酷誓,現(xiàn)在最新的是swift的語言泽示,純OC的最后一版是3.0.1版本贪染,此次使用的正是此版本壕翩。
RNCryptor源碼https://github.com/RNCryptor/RNCryptor涂乌。
基于RNCryptor有同學(xué)做了一個小工具艺栈,用來對資源文件先進(jìn)行加密。(CXYRNCryptorTool)
接下來就是在代碼中進(jìn)行解密湾盒。
解密代碼貼上
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.