Created
September 20, 2010 08:27
-
-
Save mafis/587595 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected string GetMD5HashFromFile(string fileName) | |
{ | |
if (!File.Exists(fileName)) | |
return String.Empty; | |
FileStream file = new FileStream(fileName, FileMode.Open); | |
MD5 md5 = new MD5CryptoServiceProvider(); | |
byte[] retVal = md5.ComputeHash(file); | |
file.Close(); | |
StringBuilder sb = new StringBuilder(); | |
for (int i = 0; i < retVal.Length; i++) | |
{ | |
sb.Append(retVal[i].ToString("x2")); | |
} | |
return sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment