游戲存檔加密
1. 橙光怎麼設置存檔位上鎖
存檔則悉上鎖在存檔設置裡面,自己設置一下加密就好。
橙光游戲存檔方法:點擊「緣起」進入游戲點右下角的蓮花出現四個選擇條,點擊記憶然後按一下就變成下面的樣子了並握點擊返回,下回玩的時候點擊「讀取」把絕盯慶那個框條按一下就可以載入了。
所謂橙光游戲指的是使用橙光文字游戲製作工具所製作出來的文字游戲,玩家在游戲中可以攻略男主或女主,可以統領後宮,可以仗劍江湖,可以完成夢想,可以與喜歡的明星朝夕相處。利用橙光文字游戲製作工具可以輕松製作出自己的橙光游戲。
2. 如何在 unity3D 游戲存檔加密
存檔文件, 被修改起來現在變的很容易了, 為了解決這個問題,請用下面的代碼,修改playerPrefs.cs
1.替換
fileReader = new StreamReader(fileName);
serializedInput =DecryptDES(fileReader.ReadLine(), highscore.keyss);
復制代碼
2.替換
fileWriter.WriteLine( EncryptDES(serializedOutput , highscore.keyss));
fileWriter.Close();
復制代碼
3.
//默認密鑰向量
private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };public static string keyss = "1234567z";
/// <summary>
/// DES加密字元串
/// </summary>
/// <param name="encryptString">待加密的字元串</param>
/// <param name="encryptKey">加密密鑰,要求為8位</param>
/// <returns>加密成功返回加密後的字元串,失敗返回源串</returns>
public static string EncryptDES(string encryptString, string encryptKey)
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
byte[] rgbIV = Keys;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
return Convert.ToBase64String(mStream.ToArray());
}
catch
{
return encryptString;
}
}/// <summary>
/// DES解密字元串
/// </summary>
/// <param name="decryptString">待解密的字元串</param>
/// <param name="decryptKey">解密密鑰,要求為8位,和加密密鑰相同</param>
/// <returns>解密成功返回解密後的字元串,失敗返源串</returns>
public static string DecryptDES(string decryptString, string decryptKey)
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey);
byte[] rgbIV = Keys;
byte[] inputByteArray = Convert.FromBase64String(decryptString);
DESCryptoServiceProvider DCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, DCSP.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
return Encoding.UTF8.GetString(mStream.ToArray());
}
catch
{
return decryptString;
}
}