MD5 Progress on Large Files

G

Guest

Is there any way to get progress from FileStream or MD5CryptoServiceProvider
while generating MD5 Hashes on large files (>4GB).

Or can I use a byte buffer to generate MD5 hashs that combine to create a
final hash?

StringBuilder sb = new StringBuilder();
MD5 md5 = new MD5CryptoServiceProvider();
byte[] hash = md5.ComputeHash(fs);
fs.Close();
foreach (byte hex in hash)
sb.Append(hex.ToString("x2"));
return sb.ToString();

Thanks,
Mike S
 
J

Jon Skeet [C# MVP]

Michael Slattery said:
Is there any way to get progress from FileStream or MD5CryptoServiceProvider
while generating MD5 Hashes on large files (>4GB).

You could wrap your stream with a ProgressIndicatorStream (this doesn't
exist, I'm just making it up) which passes all the requests through to
an underlying stream and raises events when it's read a certain amount.
Sorry, I'm not expressing myself particularly well - does that make
sense?
Or can I use a byte buffer to generate MD5 hashs that combine to create a
final hash?

I don't think that would be as nice as doing it on a single stream.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top