Calculate MD5 checksum for a file

前端 未结 6 916
囚心锁ツ
囚心锁ツ 2020-11-22 08:03

I\'m using iTextSharp to read the text from a PDF file. However, there are times I cannot extract text, because the PDF file is only containing images. I download the same P

6条回答
  •  故里飘歌
    2020-11-22 08:22

    I know that I am late to party but performed test before actually implement the solution.

    I did perform test against inbuilt MD5 class and also md5sum.exe. In my case inbuilt class took 13 second where md5sum.exe too around 16-18 seconds in every run.

        DateTime current = DateTime.Now;
        string file = @"C:\text.iso";//It's 2.5 Gb file
        string output;
        using (var md5 = MD5.Create())
        {
            using (var stream = File.OpenRead(file))
            {
                byte[] checksum = md5.ComputeHash(stream);
                output = BitConverter.ToString(checksum).Replace("-", String.Empty).ToLower();
                Console.WriteLine("Total seconds : " + (DateTime.Now - current).TotalSeconds.ToString() + " " + output);
            }
        }
    

提交回复
热议问题