How to encrypt bundled text/json files?

倾然丶 夕夏残阳落幕 提交于 2019-12-09 19:33:01

问题


I have a couple of files bundled with my iOS app. Now - if someone would download the app, and access the .ipa file, he could easily read them. I would like to make it harder.

Do you know of any resources dealing with the subject? I guess I need an encryption library, and some scripts in my build script encoding the file...

Of course I know that someone may decompile my sources and break the code, but I just want it to be harder.


回答1:


As @Alex point out since the key will be in the source code this is not secure.

Use CommonCryptor from CommonCrypto

#import <CommonCrypto/CommonCryptor.h>

// Stateless, one-shot encrypt or decrypt operation.

    CCCryptorStatus CCCrypt(
        CCOperation op,
        CCAlgorithm alg,
        CCOptions options,
        const void *key, size_t keyLength,
        const void *iv,
        const void *dataIn, size_t dataInLength,
        void *dataOut,
        size_t dataOutAvailable, size_t *dataOutMoved);

But, this will give you export restrictions. You might be just as happy using base64 which is not cryptography and has no export restrictions.

In any case the first thing you need to decide on is the threat model, how sensitive is the data, how severely do you want to restrict access and how much pain are you willing to accept.



来源:https://stackoverflow.com/questions/6315255/how-to-encrypt-bundled-text-json-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!