Skip to content

Instantly share code, notes, and snippets.

@mchesterkadwell
Created April 4, 2018 08:23
Show Gist options
  • Select an option

  • Save mchesterkadwell/cb16089f618989ba5ad8942235603a98 to your computer and use it in GitHub Desktop.

Select an option

Save mchesterkadwell/cb16089f618989ba5ad8942235603a98 to your computer and use it in GitHub Desktop.
Checks the sha256 checksum of a file against the official checksum provided by the owner
#!/bin/bash
# Quick hack to check the sha256 checksum of a file against the official checksum provided by a vendor
# Apols, code not blessed with an overabundance of checking inputs
# To run as a shell script don't forget to make executable
if [ "$#" -eq "2" ]; then
filename=$1
official_hash=$2
local_hash="$(sha256sum $filename | head -c 64)"
if [ "$official_hash" == "$local_hash" ]; then
echo "Yey! :) Hashes match for "$filename""
else
echo "Oh no. :( Hashes do not match for "$filename""
fi
else
echo "Usage: ./checkchecksum.sh <file> <hash>"
echo "You provided $# parameters, but 2 are required."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment