修复 FIPS 问题

FIPS问题简单来讲就是不让用MD5,太逊了
This commit is contained in:
ZouJin 2024-02-02 21:42:23 +08:00
parent 0bf3f7e4f8
commit bc6aff6974
2 changed files with 40 additions and 7 deletions

View File

@ -1,13 +1,17 @@
using LinePutScript;
using LinePutScript.Dictionary;
using LinePutScript.Localization.WPF;
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using VPet_Simulator.Core;
using static System.Net.Mime.MediaTypeNames;
namespace VPet_Simulator.Windows.Interface
{
@ -55,9 +59,28 @@ namespace VPet_Simulator.Windows.Interface
if (nohashcheck)
{
hash = lps.GetInt64("hash");
int ver = lps["hash"].GetInt("ver");
if (lps.Remove("hash"))
{
HashCheck = Sub.GetHashCode(lps.ToString()) == hash;
if (ver == 2)
HashCheck = Sub.GetHashCode(lps.ToString()) == hash;
else
{
try
{
using (MD5 md5 = MD5.Create())
{
HashCheck = BitConverter.ToInt64(md5.ComputeHash(Encoding.UTF8.GetBytes(lps.ToString())), 0) == hash;
}
if (!HashCheck)
HashCheck = Sub.GetHashCode(lps.ToString()) == hash;
}
catch (Exception e)
{
HashCheck = false;
MessageBoxX.Show(e.ToString(), "当前存档Hash验证信息".Translate() + ":" + "失败".Translate());
}
}
}
}
@ -109,16 +132,23 @@ namespace VPet_Simulator.Windows.Interface
if (HashCheck)
{
lps[(gi64)"hash"] = Sub.GetHashCode(lps.ToString());
lps["hash"][(gint)"ver"] = 2;
}
else
{
lps[(gint)"hash"] = -1;
lps["hash"][(gint)"ver"] = 2;
}
return lps;
}
/// <summary>
/// Hash检查
/// </summary>
public bool HashCheck { get; private set; } = true;
FInt64 IGetOBJ<ILine>.this[gflt subName] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
/// <summary>
@ -132,7 +162,7 @@ namespace VPet_Simulator.Windows.Interface
#region GETOBJ
public DateTime this[gdat subName] { get => Data[subName]; set => Data[subName] = value; }
public double this[gflt subName] { get => Data[subName]; set => Data[subName] = value; }
public FInt64 this[gflt subName] { get => Data[subName]; set => Data[subName] = value; }
public double this[gdbe subName] { get => Data[subName]; set => Data[subName] = value; }
public long this[gi64 subName] { get => Data[subName]; set => Data[subName] = value; }
public int this[gint subName] { get => Data[subName]; set => Data[subName] = value; }
@ -170,12 +200,12 @@ namespace VPet_Simulator.Windows.Interface
Data.SetInt64(subName, value);
}
public double GetFloat(string subName, double defaultvalue = 0)
public FInt64 GetFloat(string subName, FInt64 defaultvalue = default)
{
return Data.GetFloat(subName, defaultvalue);
}
public void SetFloat(string subName, double value)
public void SetFloat(string subName, FInt64 value)
{
Data.SetFloat(subName, value);
}

View File

@ -637,7 +637,7 @@ namespace VPet_Simulator.Windows
{
var stat = GameSavesData.Statistics;
var save = Core.Save;
stat["stat_money"] = save.Money;
stat["stat_money"] = (SetObject)save.Money;
stat["stat_level"] = save.Level;
stat["stat_likability"] = save.Likability;
@ -1425,12 +1425,16 @@ namespace VPet_Simulator.Windows
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载游戏动画".Translate()));
await Dispatcher.InvokeAsync(new Action(() =>
{
LoadingText.Content = "尝试加载动画和生成缓存".Translate();
LoadingText.Content = "尝试加载动画和生成缓存\n该步骤可能会耗时比较长\n请耐心等待".Translate();
Core.Graph = petloader.Graph(Set.Resolution);
Main = new Main(Core);
Main.NoFunctionMOD = Set.CalFunState;
LoadingText.Content = "正在加载游戏".Translate();
//加载数据合理化:工作
if (!Set["gameconfig"].GetBool("noAutoCal"))
{
@ -1459,7 +1463,6 @@ namespace VPet_Simulator.Windows
}
LoadingText.Content = "正在加载游戏".Translate();
var m = new System.Windows.Controls.MenuItem()
{
Header = "MOD管理".Translate(),