How to generate a SHA512 hash for a file in Linux, Mac and Windows
SHA512 hashes are a great way to create a unique signature for file so that you can be sure it is the same and unaltered.
The way a hash is calculated means that even a very small change (e.g. just changing a space or one character) will result in a radically different hash; so it is very clear that the file has been altered when hashes are compared.
The chance of collision (two different files having the same hash) using SHA512 is stated as 1.4×10^77, (that’s one in 1,400,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000). To put this into context, the number of grains of sand on the entire planet Earth is calculated as 7.5 x 10^18; just a mere 75,000,000,000,000,000,000.
So the chance of two files having the same hash is astronomically improbable.
We use SHA512 hashes to create a unique signature for files whenever we supply duplicate works, as this (in conjunction with a verified digitally signed manifest) is a great way to verify that a file is exactly the same and has not been altered.
How to generate a SHA512 hash on a file in Linux or Mac OS
Open a command line / terminal and type:
sha512sum -b filename
OR shasum -a 512 filename
where filename is the location of the file you want to test.
e.g. sha512sum -b 2021-01-12/myFile.doc
OR shasum -a 512 2021-01-12/myFile.doc
How to generate a SHA512 hash on a file in Windows
Open the command prompt and type:
certutil -hashfile "filename" SHA512
where filename is the location of the file you want to test.
e.g. certutil -hashfile "2021-01-12\myFile.doc" SHA512
Or, if you have Windows PowerShell installed, you can do the same from there, using this command instead:
Get-FileHash -Path filename -Algorithm SHA512