简体   繁体   中英

Encrypting iOS app binary file

I'm building an iOS app but my app binary shows all my NSStrings that I've. Is there a way to encrypt it ? I want to hide all my NSStrings from my app binary file.

You would not be able to encrypt your app binary in an secure way. You would at least need to pass the key next to the application bundle so the operating system would be able to encrypt the application before running it. And when you pass the key next to the application somebody interested in your application would be able to decrypt it too. So encrypting the whole binary file would be useless.


Do you ship passwords or API keys with your app bundle?

The best deal would be to redesign your application so such stuff isn't needed. You could try to prevent user from reading them directly out of your binary file, but they would always be able to get them. A couple of very smart guys have already tried that and failed, so don't waste your time trying to be better then them. So don't ship passwords or API keys!


If you still want to ship sensitive data in your binary:

You could give the following a try:

NSString *encryptedSensitiveString = @"mysensitivdatapreviosulyencpryted"; // <- this will be stored in your binary since it's a constant string

NSString *sensitiveString = [someHiddenKey decryptString:encryptedSensitiveString];
// Now you can use your sensitive string which is decrypted at runtime

If you are looking for some cryptography library for Objective-C you can use MIHCrypto framework based on OpenSSL .

As someone already stated, building or decrypting the strings dynamically is one choice.

Another is to use a 3rd party app protection system, like Arxan . I have never personally used it so can't really recommend it, but it does all sorts of obfuscation to prevent users from peeking into your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM