在iOS设备上本地保存游戏得分...需要安全吗? [英] Saving game score locally on iOS device...is security needed?
问题描述
我是否需要用散列来存储分数,即保护它免于被用户编辑/欺骗?从我的newb知识来看,用户无法查看和操作本地存储的数据,例如plist文件。任何人都可以详细说明吗?
我在本地存储分数,并定期将它们上传到Game Center排行榜。即使该设备越狱,我想要有安全防止分数被用户操纵。什么是好方法?
我实际上会这样做:
<将它保存在 NSDictionary
中,并将其转换为 NSData
对象。现在来了一个很酷的部分:
使用这个类将它加密成AES:
https:// web。 archive.org/web/20160806074714/http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html
这是一个军事标准加密,它将返回一个加密的 NSData
对象。然后只要将它保存到文件并在必要时读/写。我对这个课程有着非常好的经验,用户也无法做任何事情。
比使用<$ c $存储它简单得多c> NSUserDefaults 。
试试吧!
Do I need to store the score with a hash, ie to protect it from being edited/cheated by a user? From my newb knowledge, the user is unable to view and manipulate this locally stored data, as plist files for example. Can anyone elaborate?
[Edit] I'm storing scores locally and periodically uploading them to Game Center leaderboards. Even if the device is jailbroken I'd like to have security to prevent scores being manipulated by the user. What is a good approach?
I actually would do this:
Save it in an NSDictionary
and convert it to an NSData
object. Now comes the cool part:
Encrypt it into AES using this class:
https://web.archive.org/web/20160806074714/http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html
This is a military standard encryption which will return an encrypted NSData
object. Then just save it to file and read/write whenever necessary. I've had really good experiences with this class and the user can't do anything to it.
Much better than just storing it in plain sight using NSUserDefaults
.
Give it a go!
这篇关于在iOS设备上本地保存游戏得分...需要安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!