C#的MD5计算问题 [英] C# MD5 calculation issue

查看:207
本文介绍了C#的MD5计算问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VSTS 2008 + C#+ .NET 3.0。我想找到计算MD5结果一个txt文件的全部内容的最有效方式。

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?

在此先感谢, 乔治

推荐答案

一些简单的:

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.

这篇关于C#的MD5计算问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆