Advertisement
destr0y

GetMD5

Dec 18th, 2019
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. public static string GetMD5(string fileName)
  2. {
  3.     try {
  4.         var file = new FileStream(fileName, FileMode.Open);
  5.         var md5 = new MD5CryptoServiceProvider();
  6.         byte[] retVal = md5.ComputeHash(file);
  7.         file.Close();
  8.         file.Dispose();
  9.  
  10.         var sb = new StringBuilder();
  11.  
  12.         foreach (var t in retVal)
  13.             sb.Append(t.ToString("x2"));
  14.  
  15.         return sb.ToString();
  16.     }
  17.     catch { return ""; }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement