forked from sin365/AxibugEmuOnline
RemoteRoms文件夹中的Rom文件现在会和服务器提供的hash进行比较,以确定该文件是否合法,不合法会被移除
This commit is contained in:
parent
abc68f68c3
commit
e1fb708d6e
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user