From e1fb708d6ee4ff841586988b577b69eb1087534c Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Fri, 20 Sep 2024 17:16:30 +0800 Subject: [PATCH] =?UTF-8?q?RemoteRoms=E6=96=87=E4=BB=B6=E5=A4=B9=E4=B8=AD?= =?UTF-8?q?=E7=9A=84Rom=E6=96=87=E4=BB=B6=E7=8E=B0=E5=9C=A8=E4=BC=9A?= =?UTF-8?q?=E5=92=8C=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=8F=90=E4=BE=9B=E7=9A=84?= =?UTF-8?q?hash=E8=BF=9B=E8=A1=8C=E6=AF=94=E8=BE=83,=E4=BB=A5=E7=A1=AE?= =?UTF-8?q?=E5=AE=9A=E8=AF=A5=E6=96=87=E4=BB=B6=E6=98=AF=E5=90=A6=E5=90=88?= =?UTF-8?q?=E6=B3=95,=E4=B8=8D=E5=90=88=E6=B3=95=E4=BC=9A=E8=A2=AB?= =?UTF-8?q?=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/Common/Helper.cs | 14 ++++++++++++++ .../Assets/Script/Manager/RomLib/RomLib.cs | 11 ++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs b/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs index 6cf5c99..6d64427 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs @@ -59,5 +59,19 @@ namespace AxibugEmuOnline.Client.Common } } } + public static string FileMD5Hash(byte[] data) + { + using (var md5 = MD5.Create()) + { + using (var stream = new MemoryStream(data)) + { + var hash = md5.ComputeHash(stream); + var sb = new StringBuilder(hash.Length * 2); + foreach (var b in hash) + sb.AppendFormat("{0:x2}", b); + return sb.ToString(); + } + } + } } } diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs index 1aafdac..b4105d9 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs @@ -1,4 +1,5 @@ using AxibugEmuOnline.Client.ClientCore; +using AxibugEmuOnline.Client.Common; using System; using System.Collections.Generic; using System.IO; @@ -116,15 +117,7 @@ namespace AxibugEmuOnline.Client public static string CalcHash(byte[] data) { - return string.Empty; //todo : 等待远程仓库敲定hash算法 - //var hashBytes = MD5.Create().ComputeHash(data); - //StringBuilder sb = new StringBuilder(); - //foreach (byte b in hashBytes) - //{ - // sb.Append(b.ToString("x2")); - //} - - //return sb.ToString(); + return Helper.FileMD5Hash(data); } } }