Always Make The Checksum Check!

I have to admit, I have always been quite careless when it came to downloading installation packages. Though after some unpleasant situations of dealing with corrupted files, I made it a habit to make a checksum check every time I want to download an installation package or image.


It might seem quite time-consuming at first, but as soon it becomes a habit, you won't even notice the effort you made.

Making the checksum check on Windows is quite easy, you only have to run your PowerShell and use the Get-FileHash command. It would look somehow like that:


Get-FileHash C:\YourFilePath -A SHA56

-A specifies an algorithm and then we type the algorithm that was used to create the hash value.


But since it is quite a task to compare hash values character by character, we can use a simple script that would compare the hash values and give us the result in a boolean value.

The script would look something like that:


(Get-FileHash C:\YourFilePath -A SHA56).hash -eq "insertthehashvalue"

We use Get-FileHash command for our file and use -eq to compare it to the value that was included in the file description on the source we download the file from. The result of the script will come out as True or False, which will let us know if hash values match or not.


More details about how to use the Get-FileHash command can be found on the official site of Microsoft.


To make the checksum check on Linux you can use the tools for hash algorithms that are included in the distro. For example, it would be md5sum for MD5 algorithm, sha1sum for SHA-1 algorithm, or, like in my case, sha256sum for SHA-256 hash algorithm.


sha256sum filename


Don't forget that to use those commands to make the checksum check, you will have to be in the directory where the file is located.


Since the output of the command includes the name of the file, I found it hard to make an easy script that would be useful to compare checksum values (without returning forever False :D), and that would be easier to type rather than just visually compare the checksum values. But if you, guys, have an idea how to automate checksum check that in Linux, please, share your ideas!