Computing MD5SUM of large files in C#

后端 未结 1 1091
粉色の甜心
粉色の甜心 2020-12-14 12:17

I am using following code to compute MD5SUM of a file -

byte[] b = System.IO.File.ReadAllBytes(file);
string sum = BitConverter.ToString(new MD5CryptoServic         


        
相关标签:
1条回答
  • 2020-12-14 12:58

    I suggest using the alternate method:

    MD5CryptoServiceProvider.ComputeHash(Stream)
    

    and just pass in an input stream opened on your file. This method will almost certainly not read in the whole file in memory in one go.

    I would also note that in most implementations of MD5 it's possible to add byte[] data into the digest function a chunk at a time, and then ask for the hash at the end.

    0 讨论(0)
提交回复
热议问题