How to encrypt bundled text/json files?

2019-04-14 14:12发布

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条回答
欢心
2楼-- · 2019-04-14 14:52

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.

查看更多
登录 后发表回答