How To Calculate MD5 Checksum In Windows?

MD5 is a message-digest algorithm or hash algorithm used to check the integrity of the files and data. Even it is assumed as non-secure or broken it is widely used because of its roots and popularity. Windows operating systems like Windows XP, Windows 10, Windows Server provides different tools to calculate MD5 hash. In this tutorial, we examine how to calculate MD5 for Windows operating systems.

Calculate MD5 with CertUtil Command

The CertUtil is a tool created for certification operations. It can calculate the different types of hash values like Sha1, Sha256 as well as MD5. the certuil is provided in all Windows operating systems like Windows 10, Windows XP, Windows 7, and Windows Server versions by default and there is no need for extra install. In the following example, we calculate the MD5 hash for the file specified as “db.csv”. Also, the "MD5" is added at the end of the command as a parameter. The certuil tool can be used for both MS-DOS command prompt and PowerShell without any problem.

> certutil -hashfile db.csv MD5
MD5 hash of db.csv:
CertUtil: -hashfile command completed successfully.

From the output of the MD5 calculation, the file name the MD5 hash digest is provided. Also, the calculation operation status is displayed as successful.

If we do not want to print all output for the calculation and only print the MD5 value the findstr command can be used to show only the MD5 value.

> certutil -hashfile db.csv MD5 | findstr -v ash

Calculate MD5 with Get-FileHash PowerShell Command

PowerShell provides the Get-FileHash commandlet which can be used to calculate file hashes like SHA1, SHA256, MD5, etc. We can calculate the MD5 hash for a file by using the Get-FileHash. By default, the Get-FileHash calculates the SHA256 hash value. We can use the -Algorithm option to set hash type as MD5 and calculate MD5 hash value like below.

PS> Get-FileHash -Algorithm MD5 .\db.csv
Calculate MD5 with Get-FileHash PowerShell Command

The Get-FileHash commandlet can be also called from the MS-DOS commandline interface if the PowerShell is installed. The PowerShell interpreter is added before the Get-FileHash command and called from the MS-DOS like below.

> PowerShell Get-FileHash -Algorithm MD5 .\db.csv
Calculate MD5 with Get-FileHash PowerShell Command In MS-DOS
See also  Export To CSV File In PowerShell with Export-Csv Command

Leave a Comment