Unity保存负载安全(Unity Save load Int securely)

编程入门 行业动态 更新时间:2024-10-22 11:08:08
Unity保存负载安全(Unity Save load Int securely)

我需要Unity的C#代码,以某种安全的方式保存和加载int:iOS,Android,Windows,Mac,Linux。 它不一定非常安全,但至少玩家不能通过用记事本或类似东西打开它来改变它。

我不在乎怎么样,或者它是否是超级加密的安全,或者只是简单地转换数据的情况,是否使用播放器prefs转换为字节(一直试图无效)或者是否创建一个新的文件安装的游戏以某种方式加密。 只是有用的东西!

I need C# code for Unity that saves and loads an int in some secure manner compatible with: iOS, Android, Windows, Mac, Linux. It doesn't have to be super secure, but at least the player can't just change it by opening it with notepad or something like that.

I don't care how anymore, or whether it is super encrypted secure, or just a case of simply converting the data, whether it uses player prefs converting to bytes (been trying to no avail) or whether to create a new file where the game is installed that is encrypted in some manner. Just something that works!

最满意答案

你应该看一下这个插件: https : //www.assetstore.unity3d.com/en/#!/ content / 32357

免费且易于使用。 你先用它初始化它

ZPlayerPrefs.Initialize("somePasswordString", "someSaltString");

使用:

// Write ZPlayerPrefs.SetInt("foo", 10); // Read int i = ZPlayerPrefs.GetInt("foo", -1 /*default value*/ );

在那里使用的加密非常弱(DES),但是如果你说你不需要它那么超级安全。 它将适用于所有平台,因为它使用PlayerPrefs作为后端,这是跨平台的。

这里也有类似的东西http://forum.unity3d.com/threads/playerprefs-encryption.26437/但是它非常弱,只是带有一些盐的MD5校验和来检查没有人搞乱你的数据。

如果您需要强加密,我建议您查看SOOMLA框架,该框架本机使用数据库实现AES加密的KeyValueStorage 。 在没有本机代码的情况下在C#中添加更强的加密可能是一个挑战,因为Mono没有实现许多System.Security.Cryptography类,因此您必须手动完成大部分工作。

You should check out this plugin: https://www.assetstore.unity3d.com/en/#!/content/32357

Free and easy to use. You initialize it first with

ZPlayerPrefs.Initialize("somePasswordString", "someSaltString");

The to useit:

// Write ZPlayerPrefs.SetInt("foo", 10); // Read int i = ZPlayerPrefs.GetInt("foo", -1 /*default value*/ );

The encryption used there is quite weak (DES), but if you say you don't need it super secure that will do. And it will work on all platforms, as it uses PlayerPrefs as backend, which is cross platform.

There is also something similar here http://forum.unity3d.com/threads/playerprefs-encryption.26437/ but it is very weak, just MD5 checksum with some salt to check nobody messed with your data.

If you need strong encryption, I suggest you check out SOOMLA framework, which implements AES encrypted KeyValueStorage natively using a database. Adding a stronger encryption in C# without native code may be a challenge, since Mono does not implement many System.Security.Cryptography classes, so you will have to do most of the job manually.

更多推荐

本文发布于:2023-04-29 08:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335916.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:负载   Save   Unity   securely   Int

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!