JSON统一加密的最佳方法?
我正在为Android开发我的第一个手机游戏,并且正在试图找出加密我的JSON Local保存数据的最佳方法,我知道加密并不能使100%安全地安全到元数据,那么其他游戏有什么作用为保护其本地数据做出强大的加密吗? 也许他们在元数据中制作了多个加密算法? 如果是这样,我知道AES加密算法,我还可以将其他算法结合使用?
I'm developing my first game for mobile for android and I'm trying to figure out the best way to encrypt my JSON local save data,I know that encryption doesn't make 100% secure to metadata, so what do other games do to make a strong encryption to protect their local data?
Maybe they make more than one encryption algorithm in their metadata?
If so, I know AES encryption algorithm, what other algorithm can I combine it with?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
加密保存数据仅保护其免受直接文件操作的影响。精明的作弊者可以使用十六进制编辑器和代码注入在运行时修改游戏值。
话虽这么说,任何将您的保存数据转换为非平面文物的东西都将阻止大多数作弊。 “安全的本地保存数据”的层通常是:
最容易作弊 - 明文JSON。用户可以直接操纵这些值。大多数玩家可以轻松修改这些值。
稍微复杂 -Base64编码。用户可以解码此数据并对其进行修改,而无需反编译代码或搜索加密密钥。大多数球员都不知道该怎么做。
更复杂的 - 使用System.Security.Cryptography的AES加密。用户需要加密密钥,以便对保存文件进行任何更改。很少有用户可以拥有技术知识。
基于服务器的加密和验证 - 由于加密密钥在服务器上,因此用户不可能直接在本地修改文件。
请记住,以上解决方案都没有阻止用户使用十六进制编辑器或代码注入在运行时直接修改游戏值。如果您想完全防止任何运行时数据修改,则需要在权威服务器上运行游戏,而您构建的应用只能用作客户端。
在我的经验中,试图防止作弊是一场非常困难的军备竞赛。您最好花费开发时间使游戏变得有趣,而不是保持本地托管游戏的竞争诚信。
Encrypting save data only protects it from direct file manipulation. Savvy cheaters can use hex editors and code injection to modify game values at runtime.
That being said, anything that converts your save data into something non-plaintext will prevent the majority of cheating. The layers of "secure local save data" are typically:
Easiest to cheat - Plaintext JSON. A user can directly manipulate these values. Most players can modify these values easily.
Slightly more complex - Base64 encoded. A user can decode this data and modify it without needing to decompile code or hunt down the encryption key. Most players will not know how to do this.
Even more complex - AES encryption using System.Security.Cryptography. A user needs the encryption key in order to make any changes to the save file. Very few users will have technical knowledge to do this.
Server-based encryption and verification - Since the encryption key is on the server, it is impossible for a user to directly modify the file locally.
Keep in mind, none of the above solutions prevent a user from directly modifying game values during runtime using a hex editor or code injection. If you want to prevent any runtime data modification at all, you'll need to run your game on an authoritative server, and the app you build would only serve as the client.
In my experience, trying to prevent cheating is an arms race that is very difficult to win. You're better off spending your development time making the game fun to play than maintaining competitive integrity for locally hosted games.