How do I create an MD5 hash digest from a text file?

后端 未结 4 1135
终归单人心
终归单人心 2020-12-05 18:12

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 u

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 18:42

    Short and to the point. filename is your text file's name:

    using (var md5 = MD5.Create())
    {
        return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filename))).Replace("-", "");
    }
    

提交回复
热议问题