1

I am looking for a way to secure my app resources with Encrypt ( & Decrypt at run time) the app resources (images, db, NSUserDefault values, other files etc).

Is there any easy way to do so?

ARS
  • 147
  • 1
  • 8
  • 1
    possible duplicate of [Encryption of contents in compiled iOS app ( IPA )](http://stackoverflow.com/questions/6211274/encryption-of-contents-in-compiled-ios-app-ipa) – Raptor Apr 04 '14 at 06:29
  • 1
    @Raptor There are many such ways for encryption. But i want a way where i can decrypt resources which are set in XIB(Button images, image view images etc). Is there any way for this? – ARS Apr 04 '14 at 07:07
  • 1
    XIB stores layout. Why do you want to encrypt a layout? It will be displayed to users anyway. Also, layout is compiled, only images are not encrypted. – Raptor Apr 04 '14 at 07:22
  • 1
    @Raptor: I do not want to encrypt the XIB file, but my point is if I set an Image to the UIImageview in XIB then where to decrypt the UIImage assigned to that imageview? As we cannot get imagename from UIImage. I hope this clarifies my question. – ARS Apr 04 '14 at 09:27
  • You can convert the `UIImage` to `NSData` and encrypt the `NSData` with your favorite encryption algorithm (e.g. DES, RSA, etc) – Raptor Apr 04 '14 at 09:49
  • @Raptor : How to convert decrypted UIImage to NSData? I am using this but it returns invalid data: ` NSData *dat=UIImagePNGRepresentation(self.image);` – ARS Apr 04 '14 at 10:34
  • What do you mean by invalid data ? – Raptor Apr 04 '14 at 10:53
  • 1
    As UIImage is encrypted it is not a valid png file so as per apples documentation "UIKIT_EXTERN NSData *UIImagePNGRepresentation(UIImage *image); // return image as PNG. May return nil if image has no CGImageRef or invalid bitmap format " it returns invalid data. – ARS Apr 04 '14 at 11:00
  • Note that if your resources can be decrypted at runtime then a dedicated attacker can extract them in the same way. For the same reason DRM does not work in practice. – Perseids Apr 13 '14 at 10:08

0 Answers0