Using C#, I want to create an MD5 hash of a text file. How can I accomplish this?
Update: Thanks to everyone for their help. I’ve finally settled upon the following code –
// Create an MD5 hash digest of a file
public string MD5HashFile(string fn)
{
byte[] hash = MD5.Create().ComputeHash(File.ReadAllBytes(fn));
return BitConverter.ToString(hash).Replace("-", "");
}
Here’s the routine I’m currently using.