Calculate MD5 checksum for a file

前端 未结 6 947
囚心锁ツ
囚心锁ツ 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:23

    Here is a slightly simpler version that I found. It reads the entire file in one go and only requires a single using directive.

    byte[] ComputeHash(string filePath)
    {
        using (var md5 = MD5.Create())
        {
            return md5.ComputeHash(File.ReadAllBytes(filePath));
        }
    }
    

提交回复
热议问题