What is a checksum and how do I use it

Verifying item an from internet?

Sebastiaan avatar
  • Sebastiaan
  • 2 min read

What is a checksum

A Checksum is a digital fingerprint of a file or code. Software creators and/or companies are creating these digital fingerprints for safety reasons. One of the most common usecases is checking if a downloaded file is changed by a third party. if the checksum is different from the one that the creators provided, it most likely has been corrupted or tampered with.

We dont need external programs or a website (where we need to upload a file) to give us a checksum of a file. It is fairly easy and shown down below in two categories: Windows and Linux(MacOS).

Windows

By clicking on the windows icon on the server (given it is in graphic mode otherwise your already in a terminal) or desktop. Search for Powershell or Command Prompt, we do not need elevated priveleges (admin rights) on the machine. Then we run the following command;

certutil -hashfile <filename> [HashAlgorithm] 

The following HashAgoriths can be used: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512

Linux

When on desktop, find the launcher and search for terminal or use the keyboard shortcut: ctrl-alt-t On a server you are already on the systems terminal.

[HashAlgorithm]sum <filename>

The following HashAgoriths can be used: MD5 SHA1 SHA256 SHA384 SHA512

Example

This example works the same on linux with different commands. i’ve created a test.txt file with some info text in it.LEts check the hash

certutil -hashfile test.txt sha256

Output

SHA256 hash of test.txt:
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
CertUtil: -hashfile command completed successfully.

When we change the text inside the test.txt file and run the command again, the hash changes:

SHA256 hash of test.txt:
a5b40cf7147479b452c3b51feefc2f7cd0c926121033b2cfd09f1ae1c825ec30
CertUtil: -hashfile command completed successfully.

An overview of the changed sha256 checksums.

Initial: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
changed: a5b40cf7147479b452c3b51feefc2f7cd0c926121033b2cfd09f1ae1c825ec30
Sebastiaan

Written by : Sebastiaan

Sysadmin/Platform/Devops Engineer

Recommended for You

Introduction

Introduction

The start of my New Years resolution.