MD5工具类
/***
*
* Title: MXFramework
* 主题: MD5工具类
* Description:
* 功能:
*
* Date: 2019
* Version: v1.3.0版本
* Modify Recoder:
*
*/
using System;
using System.Security.Cryptography;
using System.IO;
namespace Mx.Util
{
/// <summary>MD5工具类</summary>
public class MD5Util
{
public static string Get(string filePath)
{
try
{
FileStream fs = new FileStream(filePath, FileMode.Open);
int len = (int)fs.Length;
byte[] data = new byte[len];
fs.Read(data, 0, len);
fs.Close();
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(data);
string fileMD5 = "";
foreach (byte b in result)
{
fileMD5 += Convert.ToString(b, 16);
}
return fileMD5;
}
catch (FileNotFoundException e)
{
Console.WriteLine(e.Message);
return "";
}
}
}//class_end
}
Unity QQ交流群:299412191 欢迎对Unity感兴趣的同学加入.