客观C类如何加密 [英] How can objective C classes be encrypted

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

问题描述

我想在我的iPhone游戏中加密几个我的对象类,它处理openfeint数据和处理分数的类。



我听说有一种方法来加密这些数据,作为另一个安全级别,至少足以阻止一些人破解它,并在越狱iPhone上锻炼分数然后垃圾邮件排行榜。



如何做到这一点,什么是好的技术来保护这些数据,并阻止一些人试图欺骗数据?



谢谢

解决方案

真正加密编译代码可能比值得更麻烦。您必须将要解密的代码隔离到动态库中,并在内存中解密之后手动加载库。动态库,以及您在运行时可能用于修改代码的其他方法,在Apple与iOS配合使用时,都会受到青睐。



使用Objective-C,您基本上可以使用标题构建到您的代码中。这使您在应用程序中更容易挖掘。任何你可以在C中做的事情,其中​​的符号可能被剥离,将会稍微难以阅读。您还可以使用#define轻松模糊您的类和方法名称。这不是加密,但是更容易实现,并且不太可能引入古怪的错误。

  #define MyNicelyNamedClass somegarblegarble 
#define myNicelyNamedMethod othergarblegarble

@interface MyNicelyNamedClass

- (id)myNicelyNamedMethod;

@end

这是一个相对无痛的方式让开发人员他们的Objective-C代码对他人来说不那么明显。它与javascript混淆一样有效,也就是说这是一个更多的小障碍,会阻止许多休闲攻击者。



如果您选择有意义但误导性的名称,而不是直接的垃圾你甚至可能会欺骗某人花费时间挖掘错误的代码。不是你会知道的,但这是一个令人满意的想法。


I would like to encrypt a few of my obj c classes in my iphone game which handle openfeint data and classes which handle scores.

I have heard there is a way to encrypt this data to act as another level of security, at least enough to discourage some from cracking it and forging scores on a jailbroken iphone and then spam the leaderboards.

How is this done, what are good techniques to secure this data and discourage some from attempting to spoof data?

Thanks

解决方案

To truly encrypt compiled code is probably more trouble than it is worth. You have to isolate the code that will be decrypted into a dynamic library and load the library manually after decrypting it in memory. Dynamic libraries, and the other methods you might use to modify code at runtime, are frowned on by Apple when used with iOS.

With Objective-C you essentially ship with the headers build into your code. That makes it much easier to dig around in your application. Anything you can do in C, where symbols may be stripped, will be slightly harder to read. You can also use #define to obfuscate your class and method names a little. This is nowhere near encryption, but is much easier to implement and less likely to introduce wacky bugs.

#define MyNicelyNamedClass somegarblegarble
#define myNicelyNamedMethod othergarblegarble

@interface MyNicelyNamedClass

-(id) myNicelyNamedMethod;

@end

This is a relatively painless way for a developer to make their Objective-C code less obvious to others. It is about as effective as javascript obfuscation, which is to say it is one more little hurdle that will dissuade many casual attackers.

If you choose meaningful but misleading names instead of straight garbage you may even trick someone into spending hours digging through the wrong code. Not that you would ever know, but it is a satisfying thought.

这篇关于客观C类如何加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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