Comparison with MD5 verification and reliable files
When text extraction cannot be performed, it is a challenge to identify the downloaded PDF file. Is the MD5 verification and a reliable solution?
Answer:
Yes, even if the text and modification date cannot be accessed, the MD5 verification and the reliable method of determining whether the file is changed.
Code fragment:In C#, use system.security.cryptography.md5 name space. Calculate the MD5 verification and very simple:
The generated byte array can be compared with the previous version of the MD5 hash to detect any changes.
<code class="language-c#">using (var md5 = MD5.Create()) { using (var stream = File.OpenRead(filename)) { return md5.ComputeHash(stream); } }</code>
The above is the detailed content of Can MD5 Checksums Reliably Detect Changes in Downloaded PDF Files?. For more information, please follow other related articles on the PHP Chinese website!