如何加密捆绑的文本/ json文件? [英] How to encrypt bundled text/json files?

查看:251
本文介绍了如何加密捆绑的文本/ json文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个文件捆绑在我的iOS应用程序。
现在 - 如果有人下载应用程序,并访问.ipa文件,他可以轻松阅读它们。我想要更难。



你知道处理这个问题的任何资源吗?我想我需要一个加密库,并在我的脚本编码文件中的一些脚本...



当然,我知道有人可能反编译我的源码并打破代码,但我只是希望它更难。

解决方案

由于@Alex指出,因为该键将在源代码中不安全。



使用CommonCrypto中的CommonCryptor

  #import< ; CommonCrypto / CommonCryptor.h> 

//无状态,单次加密或解密操作。

  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);

但是,这将给你出口限制。你可能会很高兴使用base64,而不是加密技术,没有出口限制。



无论如何,你需要决定的第一件事就是威胁模型,敏感的是数据,你想要限制访问的严重程度以及你愿意接受多少痛苦。


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.

解决方案

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.

这篇关于如何加密捆绑的文本/ json文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆