You have already received answers on how to do an automatised comparison of the two hash values to ensure they are completely alike. I just wanted to add a different angle on how to compare the hash values.
Actually it is in almost any case enough to to an "eyeball comparison". I.e. if you check that first few characters and the last few characters are the same, and it "looks the same" - then this is a really good verification.
If you're trying to do an automatised comparison "by heart", there's a risk that you accidentally enter the wrong command line or somehow subtly alter the meaning of the command.
The alternative to doing it by heart is to spend time finding and cutting-pasting the script/command line every time you need to check. This can lead to situations where we simply forego the check, because we're in a hurry or feel it is low risk.
The reason why an "eyeball comparison" is most often enough is that for an attacker it is really, really hard to create a file with a SHA-256 hash that is "almost the same" as for the original file. It's almost as hard as creating a SHA-256 hash that is the same as for the original file. You could probably assume that if they can create one, they can create the other.
The properties of SHA-256 (and indeed any cryptographic hash) is such that even the slightest change to the file results in a widely different hash value.
⌘+F
in the Terminal window? – Daze Apr 21 '20 at 14:16⌘+F
just find a matching string if that string (eg. the checksum) happens to show up in the visible terminal history? – TransferOrbit Apr 21 '20 at 15:22⌘+F
in the Terminal window and if the checksum matches, it will get highlighted. If I'm not making sense, then I haven't understood your question correctly. – Daze Apr 21 '20 at 20:10shasum -a 256 -c <<< 'HASH *PATH'
, where * is for binary and there are other flags for different file types. It either prints OK or some failure. – CrnaStena Sep 06 '21 at 09:07