Created
April 4, 2018 08:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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