简体   繁体   English

加密iOS应用二进制文件

[英]Encrypting iOS app binary file

I'm building an iOS app but my app binary shows all my NSStrings that I've. 我正在构建一个iOS应用程序,但是我的应用程序二进制文件显示了我拥有的所有NSString。 Is there a way to encrypt it ? 有没有办法加密它? I want to hide all my NSStrings from my app binary file. 我想从我的应用程序二进制文件中隐藏所有我的NSStrings。

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? 您是否在应用程序包中附带密码或API密钥?

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! 因此,请勿运送密码或API密钥!


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 . 如果您正在寻找用于Objective-C的加密库,则可以使用基于OpenSSL的MIHCrypto框架

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 . 另一个方法是使用第三方应用保护系统,例如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. 我从未亲自使用过它,因此不能真正推荐它,但是它进行了各种混淆处理,以防止用户窥视您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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