Skip to content

Instantly share code, notes, and snippets.

@jimdiroffii
Created January 21, 2026 04:40
Show Gist options
  • Select an option

  • Save jimdiroffii/91e426950e4c7fe190766d4d66648482 to your computer and use it in GitHub Desktop.

Select an option

Save jimdiroffii/91e426950e4c7fe190766d4d66648482 to your computer and use it in GitHub Desktop.
SHA256 Checksum
#!/usr/bin/env bash
set -euo pipefail
expected="${1:?usage: $0 <expected_sha256> <file>}"
file="${2:?usage: $0 <expected_sha256> <file>}"
actual="$(sha256sum -- "$file" | awk '{print $1}')"
if [[ "${actual,,}" == "${expected,,}" ]]; then
echo "OK: SHA256 Match"
exit 0
else
echo "FAIL: SHA256 Does Not Match"
echo "expected: $expected"
echo "actual: $actual"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment