资源简介
高性能的内存加密类库,主要可用于各种游戏的内存加密,防止用户修改游戏数据从而影响游戏的平衡性。 可用于Unity游戏项目,集成简单,使用方便。集成后基本无需修改原来的代码逻辑,仅需要将变量声明中的int改为EncryptInt,float改为EncryptFloat……,支持int,float,...
代码片段和文件信息
/****************************************************************************
Copyright (c) home
home_498@163.com
Permission is hereby granted free of charge to any person obtaining a copy
of this software and associated documentation files (the “Software“) to deal
in the Software without restriction including without limitation the rights
to use copy modify merge publish distribute sublicense and/or sell
copies of the Software and to permit persons to whom the Software is
furnished to do so subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
using System;
namespace home.MemoryEncrypt
{
public class MemoryCheatException : Exception
{
}
class MemoryEncrypt
{
private static int key;
private static long longKey;
private static int checkKey;
private static long checkLongKey;
static MemoryEncrypt()
{
var r = new Random();
key = r.Next(0x10000000 int.MaxValue);
longKey = ((long)key << 32) + key;
checkKey = r.Next(0x10000000 int.MaxValue);
checkLongKey = ((long)checkKey << 32) + checkKey;
}
public static void Do(int value out int val out int check)
{
val = value ^ key;
check = value ^ checkKey;
}
public static int UnDo(int val int check)
{
val ^= key;
check ^= checkKey;
if (val == check)
{
return val;
}
throw new MemoryCheatException();
}
public static void Do(long value out long val out long check)
{
val = value ^ longKey;
check = value ^ checkLongKey;
}
public static long UnDo(long val long check)
{
val ^= longKey;
check ^= checkLongKey;
if (val == check)
{
return val;
}
throw new MemoryCheatException();
}
public static void Do(float value out int val out int check)
{
val = BitConverter.ToInt32(BitConverter.GetBytes(value) 0) ^ key;
check = BitConverter.ToInt32(BitConverter.GetBytes(valu
- 上一篇:C# rdlc报表嵌套子报表+源码
- 下一篇:基于C#的串口自动收发例程
相关资源
- C# AES加密解密小工具
- C#RSA加密解密签名和验证签名的小
- AES文件加密.rar
- C#使用pem格式的密钥对文件来做RSA加解
- c#文件加密解密工具含源码及工程文件
- 图像加密算法与实践
- C#加密、安全与软件注册
- C#文件加密解密及备份恢复工具
- C#作的文件加密器很不错的
- C#操作TrueCrypt加密解密
- c# 程序加密 防止反编译
- Dot.NET Reactor 混淆加密工具 完美破解版
- C#代码混淆加密工具DotFuscatorpe 4.96 完
- C#文件加密及其播放器(亲测可用)
- 域天YT88加密狗外壳加密工具
- C#最全基类源码包括ASP.NET类库、读取
- C#伪随机数加密完整源码(十分经典)
- 图像加密算法与实践:基于C#语言实现
- PC微信加密图片解密源码C#
- C# SOCKET加密文件消息传输通信
- c#下的多种字符串加密解密算法
- C# 文件加密器 源码
- C# DESC 加密解密
- 微信企业付款到银行卡、RSA加密处理
- Delphi sha1加密源码
- 用C#实现RSA的加密与解密
- RSA文件加解密C#源代码
- C#加密(DES)
- 加密算法,采用js加密,c#可以解密
- 图片与视频播放器带加密功能- C#源码
评论
共有 条评论