When software is made available for download from various sites, one way to ensure the version you’re downloading is the unaltered version the author created is to compare its checksum.

The checksum values in this example begin with sha256:. When you download the file, you can run a command to verify the checksum of the file matches the published checksum. In this example, the checksum (using the sha256 algorithm) for TagRex_1.14.2_universal.dmg should match f20ac633a4d304b65125e0acc2aed9832d1084f2ba767727456093a8a2cc159d.
For example in Linux/OSX:
> sha256 TagRex_1.13.0_universal.dmg
SHA256 (TagRex_1.13.0_universal.dmg) = eea629d3d9486d462d97e47aa4b721c2a8630b2fefe7040f5f5cb779113e6772
In the past, I’d compare the first 5-6 digits and the last 5-6 digits to the published checksum and if they were the same, I’d assume they’d be good. This is bad. The reason is it is possible to have a different file that matches the same first 6 and last 6 digits.
What’s the solution?

In other words: Be Lazy. Because I’m really lazy, I collaborated† with my favorite LLM (AI) to come up with a bash script to do this.
# shaok © 2026 by BryanH is licensed under CC BY 4.0.
# To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/
#
# Supports sha256 and md5
shaok () {
local file="$1"
local input hash algo actual
local pattern='(^|[^0-9a-f])([0-9a-f]{64}|[0-9a-f]{32})([^0-9a-f]|$)'
if [[ -z "$file" ]]
then
echo "Usage: shaok FILE [HASH]"
echo "HASH defaults to clipboard content."
return 2
fi
if [[ ! -f "$file" || ! -r "$file" ]]
then
echo "Cannot read file: $file ❌"
return 2
fi
input="${2:-$(pbpaste)}"
input="${(L)input}"
if [[ "$input" =~ $pattern ]]
then
hash="${match[2]}"
else
echo "No valid MD5 or SHA-256 hash found ❌"
return 2
fi
case "${#hash}" in
(64) algo="sha256"
actual="$(shasum -a 256 < "$file")" || return 2
actual="${actual%% *}" ;;
(32) algo="md5"
actual="$(md5 -q < "$file")" || return 2 ;;
esac
if [[ "$actual" == "$hash" ]]
then
echo "OK ✅ $file ($algo)"
return 0
else
echo "FAIL ❌ $file ($algo)"
echo "actual: $actual"
echo "expected: $hash"
return 1
fi
}
Now I copy the checksum to the clipboard and run the script against the file:
> shaok TagRex_1.14.2_universal.dmg
OK ✅ TagRex_1.14.2_universal.dmg (sha256)
†It wrote the first version, I tested it and tweaked it. It reviewed my changes and suggested updates. I applied some of them.
Why reinvent the wheel?
There are many websites that do this exact thing, why reinvent the wheel?
Security
I have no idea what they do with the file I upload. They could do nothing, or they could save it, view it, expose it to others, etc. Who knows?
If it is private info (something I’m working on for myself, or for another company), then the code is none of their business.
Accuracy
I can’t see their algorithm, so I don’t know how well it has been tested, or if it is accurate.
I’m confident I’ve tested my own script sufficiently to ensure accuracy. If proven wrong, I can update it.