38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using UnityEngine;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace BF
|
|
{
|
|
public static class GameLaunchUtils
|
|
{
|
|
public const string ABCONFIG_FILE_NAME = "ab_config.bytes";
|
|
|
|
static StringBuilder md5StringBuilder = new StringBuilder();
|
|
|
|
public static string GetFileMD5(string filePath)
|
|
{
|
|
if (!File.Exists(filePath))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
var content = File.ReadAllBytes(filePath);
|
|
return GetFileMD5(content);
|
|
}
|
|
|
|
public static string GetFileMD5(byte[] content)
|
|
{
|
|
var md5 = System.Security.Cryptography.MD5.Create();
|
|
var md5Bytes = md5.ComputeHash(content);
|
|
for (var m = 0; m < md5Bytes.Length; m++)
|
|
{
|
|
md5StringBuilder.Append(md5Bytes[m].ToString("x2"));
|
|
}
|
|
|
|
var s = md5StringBuilder.ToString();
|
|
md5StringBuilder.Remove(0, md5StringBuilder.Length);
|
|
return s;
|
|
}
|
|
}
|
|
}
|