Scripting
How To Validate Checksums on Mac

Checksum Validation in the Mac Terminal

First things first, we needed to have a file to download with a Checksum to validate. I am using this proxmox ISO download (opens in a new tab) in this example as I needed it at the time of writing this.

Once you have the file downloaded you need to generate a checksum hash locally like this:

shasum -a 512 path-to-file

Of course you will need to replace the path-to-file with an actual path to your downloaded file to be validated.

Once you have your locally generated hash, you can then create a variable in the terminal for each like so...

export checksum1=d237d70ca48a9f6eb47f95fd4fd337722c3f69f8106393844d027d28c26523d8
export checksum2=d237d70ca48a9f6eb47f95fd4fd337722c3f69f8106393844d027d28c26523d8

Followed by this command to compare the two variables you created in the previous step

diff < (printf '%s
' "$checksum1") < (printf '%s
' "$checksum2"')

If they match or there are no differences between them the terminal will return nothing and you are good to go. If there is a difference then you will see an out put somthing like this:

< d237d70ca48a9f6eb47f95fd4fd337722c3f69f8106393844d027d28c26523d8
---
> d237d70ca48a9f6eb47f95fd4fd337722c3f69f8106393844d027d28c26523d8jsdflkgjsdfkg

As you can see I have added some random characters to the second hash for dramatic effect. But you get the idea.