Skip to content

Instantly share code, notes, and snippets.

@cjjuice
Created March 12, 2019 13:33
Show Gist options
  • Save cjjuice/9d97dec383db852edf97050bc48ea51d to your computer and use it in GitHub Desktop.
Save cjjuice/9d97dec383db852edf97050bc48ea51d to your computer and use it in GitHub Desktop.
Bash functions to print and check sha256 checksums
print_checksum() {
echo $1 | shasum -a 256
}
verify_checksum() {
checksum=$(echo $1 | shasum -a 256)
if [[ $2 == "$checksum" ]]; then
echo "valid"
else
printf "invalid:\n$1 ($checksum)\nvs\n$2\n"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment