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); } } }