XOR或其他简单的文件混淆方法ios目标c [英] XOR or other simple file obfuscation method ios objective c

查看:199
本文介绍了XOR或其他简单的文件混淆方法ios目标c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用使用受版权保护的pdf文件的ios应用程序。我正在寻找一些简单的方式来混淆文件的安全性,这不需要我通过额外的大众市场CCATS加密审查过程,但也将确保版权所有者我已经做了一些保持他们的数据safa。我当然是密码保护文件,但是我想要再进一步。有没有一个简单的方法XOR或其他哈希或模糊的pdf文件我将在我的服务器上托管,然后让ios设备下载它,并将其恢复为常规密码保护的pdf文件,使用objective-c代码,以便它可以保存它在文档目录中(我不担心它在设备上的安全性,当它坐在服务器上时)。我假设对于任何文件类型来说都是一样的。

I am working on an ios application that uses copyrighted pdf files. I am looking for some simple ways to obfuscate the files for security that won't require me to go through the additional Mass Market CCATS encryption review process but will also ensure the copyright holders I've done my bit to keep their data safa. I password protect the files of course, but I want to bring it a step or two further. Is there a simple method to XOR or otherwise hash or obfuscate a pdf file I'll be hosting on my server, then have the ios device download it and restore it to a regular password protected pdf file using objective-c code so it can save it in the documents directory (I'm not worried about its security on the device as much as when it's sitting on the server). I assume that this would be the same for any filetype.

所以为了澄清我在我的桌面上找到一个简单的XOR或哈希模糊/加密方法, ios设备可以在下载后快速解码我的文件并将其保存到文档目录中的目标c代码。

So for clarification I'm looking for a simple XOR or Hash obfuscation/encryption method on my desktop that has corresponding objective c code the ios device can use to quickly decode my files after download and save it to the documents directory.

非常感谢!

这里是关于CCATS限制参考的答案...
如果使用简单的XOR密码,需要申请CCATS? / a>

here is an answer about CCATS limitations for reference ... Need to apply for CCATS if using simple XOR cipher?

推荐答案

然而,您正在下载文件,您可能会以$ code NSData的?如果是这样,你可能会有这样的东西:

However you're downloading the file, you're probably ending up with an NSData? If so, wherever you probably have something like this:

[myData writeToFile:...]

只需跳过所有字节并应用您的XOR。假设它是一个密集的8位模式,那就是:

Just dash through all the bytes and apply your XOR. Supposing it were a dense 8-bit pattern, that'd just be:

/* assuming myData is mutable... take [data mutableCopy] if required */
uint8_t *bytes = (uint8_t *)[myData mutableBytes];

for(int index = 0; index < [myData length]; index++)
    bytes[index] ^= 0xe8; // or whatever your mask is

这表明最简单的方式来应用更长的模式: p>

Which suggests the most trivial way to apply a longer pattern:

uint8_t *bytes = (uint8_t *)[myData mutableBytes];
uint8_t pattern[] = {0xe8, 0xf4, 0x98, 0x32, 0x63}; // or whatever
const int patternLengthInBytes = 5;

for(int index = 0; index < [myData length]; index++)
    bytes[index] ^= pattern[index % patternLengthInBytes];

以32位步进继续进行,但保存到磁盘可能将成为唯一有重大成本的东西,至少非常清楚。

It'd be slightly faster to proceed in 32-bit steps, but the saving to disk is probably going to be the only thing that has any significant sort of cost and that's at least very clear.

这篇关于XOR或其他简单的文件混淆方法ios目标c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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