In iOS, RNCryptor is used to encrypt resource files.
Original article: http://blog.csdn.net/chenpolu/article/details/46277587
RNCryptorSource code: https://github.com/rncryptor/rncryptor.
I made a small tool based on RNCryptor to encrypt resource files first. (CXYRNCryptorTool)
The encrypted file looks like this:
Then you can import these files to our project (Just like importing Images).
Finally, decrypt these resources: (the following code decrypts 01. cxy resources)
1 NSData * encryptedData = [NSData connector: [[NSBundle mainBundle] pathForResource: @ "incluoftype: nil]; 2 3 NSError * error; 4 NSData * decryptedData = [RNDecryptor decryptData: encryptedData 5 withPassword: @ "pwdcxy" 6 error: & error]; 7 if (! Error) {8 NSLog (@ "====== dencrypt success! ===== "); 9 UIImage * image = [UIImage imageWithData: decryptedData]; 10 _ imageView. image = image; 11 12}
Note: The decryption password must be consistent with the encryption.