C# MD5 calculation issue

时光怂恿深爱的人放手 提交于 2019-12-12 09:26:35

问题


I am using VSTS 2008 + C# + .Net 3.0. I want to find the most efficient way to calculate the MD5 result for the whole content of a txt file.

What is the most efficient solution?


回答1:


Something as simple as:

using (Stream stream = File.OpenRead(filename))
using (MD5 md5 = MD5.Create())
{
    return md5.ComputeHash(stream);
}

Given that there's no way of avoiding reading every byte of the stream, I doubt that you'll find anything significantly more efficient.



来源:https://stackoverflow.com/questions/1388702/c-sharp-md5-calculation-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!