How to Verify Checksum of a File

0

When downloading a file from the Internet it is often suggested that you verify the checksum. The checksum is usually a long list of numbers and characters which can be considered the fingerprint of the file. Verifying that the checksum of your downloaded file matches the checksum listed on the download page ensures it is genuine and intact.

Calculating the cryptographic checksum of a file in a Windows, Linux and Mac environment is fairly easy. Some might suggest downloading various tools but it is easy enough from the command line using built in features.

Launch Command Line

After downloading your file you will need to launch a command line window or terminal.

Windows
Press Windows Key+R to open the “Run” box. Type “cmd” and then click “OK”.

Linux
Press CTRL-ALT-T

Mac
Select Terminal under the Applications > Utilities menu.

Once you have a command prompt available you should navigate to the location of your downloaded file.

Calculate Hash under Windows 10

If you are running Microsoft Windows 10 you can verify the checksum of a file using the command line. To calculate the SHA256 hash of “file” use:

CertUtil -hashfile C:\path\to\file SHA256

For the other hash types you can replace SHA256 with the hash name as in these examples:

CertUtil -hashfile C:\path\to\file MD2
CertUtil -hashfile C:\path\to\file MD4
CertUtil -hashfile C:\path\to\file MD5
CertUtil -hashfile C:\path\to\file SHA1
CertUtil -hashfile C:\path\to\file SHA256
CertUtil -hashfile C:\path\to\file SHA384
CertUtil -hashfile C:\path\to\file SHA512

Calculate Hash using PowerShell

If you are familiar with PowerShell then you can run the following command to calculate the SHA256 hash of a file:

Get-FileHash C:\path\to\file -Algorithm SHA256

To calculate other hash types you can use:

Get-FileHash C:\path\to\file -Algorithm SHA1
Get-FileHash C:\path\to\file -Algorithm SHA256
Get-FileHash C:\path\to\file -Algorithm SHA384
Get-FileHash C:\path\to\file -Algorithm SHA512
Get-FileHash C:\path\to\file -Algorithm MD5

Calculate Hash under Linux

Under many of the popular Linux distributions you can use the sha256sum command to calculate the SHA256 hash of a file:

sha256sum /path/to/file

There are similar commands to calculate the SHA1, SHA512 and MD5 hashes:

sha1sum /path/to/file
sha512sum /path/to/file
md5sum /path/to/file

Calculate Hash on the Mac

On the Mac command line you can use the shasum command to calculate the SHA256 hash:

shasum -a 256 /path/to/file

Replacing “256” with 1,224,384 or 512 allows you to calculate other hashes:

shasum -a 1 /path/to/file
shasum -a 224 /path/to/file
shasum -a 384 /path/to/file
shasum -a 512 /path/to/file

Verify the Checksum

Finally once you have calculated the checksum simply compare the output to the value shown by the commands above to the one on the download page.

Here is an example using Linux where I downloaded a file “npp.7.9.2.Installer.exe” and verified that the checksum matched the checksum published by the author.

Verify Checksum example in Linux.
Share.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.