Skip to content

Commit

Permalink
[feat][runtime]:增加从FileStream计算md5的接口
Browse files Browse the repository at this point in the history
  • Loading branch information
CatImmortal committed Aug 9, 2023
1 parent 7f71576 commit b8c5489
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Assets/CatAsset/Runtime/Misc/RuntimeUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,20 @@ public static string GetFileMD5(string filePath)
{
using (FileStream fs = new FileStream(filePath,FileMode.Open))
{
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
{
byte[] bytes = md5.ComputeHash(fs);
string result = MD5BytesToString(bytes);
return result;
}
return GetFileMD5(fs);
}
}

/// <summary>
/// 获取文件MD5
/// </summary>
public static string GetFileMD5(FileStream fs)
{
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
{
byte[] bytes = md5.ComputeHash(fs);
string result = MD5BytesToString(bytes);
return result;
}
}

Expand Down

0 comments on commit b8c5489

Please sign in to comment.