隐藏(或加密)应用程式资源? [英] Hiding (or encrypting) app resources?

查看:152
本文介绍了隐藏(或加密)应用程式资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个Cocoa应用程序,它具有我希望保护但仍然显示的某些资源(图像)。通常,只是将这些放在resources文件夹中,但存储在那里使得它很容易抓取和使用。有什么办法保持这些图像隐藏,但仍然在应用程序中访问他们?

解决方案

简单解决方案





然后检索具有如下内容的特定文件:

将所有文件合并为一个大数据文件,  NSData * dataFile = [NSData dataWithContentsOfFile:filePath]; 
NSData * theFile = [dataFile subdataWithRange:NSMakeRange(startPos,endPos)];

这不能真正保护文件,

但是阻止人们简单拖拽资源。

至少数据文件不可用,当然含有盐。



另一种解决方案: / p>

为每个资源创建NSData对象。

将所有对象添加到NSMutableArray。

将数组转换为一个大的NSData对象。

将NSData对象写入文件。

并将其添加到resources文件夹中。



您的应用程序可以读取数据文件。

并使用资源检索数组。

  //将数组转换为数据
NSData * data = [NSKeyedArchiver archivedDataWithRootObject:theArray];

使用NSKeyedUnarchiver再次检索数组。


I've developing a Cocoa app that has certain resources (images) which I wish to protect, but still display. Normally one would just place these in the resources folder, but storing there makes it quite easy to grab and use. Is there any way to keep these images hidden, but still access them within the app?

解决方案

Simple solution:

Merge all files into one big data-file, optionally using 'salts'.
Then retrieve specific files with something like this:

NSData *dataFile = [NSData dataWithContentsOfFile:filePath];  
NSData *theFile = [dataFile subdataWithRange: NSMakeRange(startPos,endPos)];

This does not really protect the files,
but prevents people simply dragging out the resources.
At least, the data-file is unusable, certainly with salts.

Another solution:

Create NSData object for every resource.
Add all objects to a NSMutableArray.
Convert the array to one big NSData object.
Write the NSData object to a file.
And add it to the resources folder.

Your app can then read the data-file.
And retrieve the array with the resources.

// Convert array to data
NSData* data=[NSKeyedArchiver archivedDataWithRootObject:theArray];

Use NSKeyedUnarchiver to retrieve the array again.

这篇关于隐藏(或加密)应用程式资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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