Calculate MD5 checksum for a file

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

    This is how I do it:

    using System.IO;
    using System.Security.Cryptography;
    
    public string checkMD5(string filename)
    {
        using (var md5 = MD5.Create())
        {
            using (var stream = File.OpenRead(filename))
            {
                return Encoding.Default.GetString(md5.ComputeHash(stream));
            }
        }
    }
    

提交回复
热议问题