Skip to content

Instantly share code, notes, and snippets.

@chibby0ne
Last active February 18, 2018 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chibby0ne/0a7d459a437dfe09b6f32f6a729fda51 to your computer and use it in GitHub Desktop.
Save chibby0ne/0a7d459a437dfe09b6f32f6a729fda51 to your computer and use it in GitHub Desktop.
How to verify sha256sum without a SHASUMS file on command line

To verify a shasum or any other integrity hash, from a website that hosts a file with its shasum, you would normally take the following approach:

  1. Download the file and its SHASUMS file and place both of these files in the same directory
  2. run sha256sum -c SHASUMS

If the file integrity is intact then it would output:

filename: OK

But what if you only have the file and the shasum and no file? Case in point: Downloading boost libraries from official website

You could do a step before step 1 by creating a properly formatted SHASUM file, using the SHASUM taken from the website and the file name.

But a faster and easier way is by using pipes and running shasum using standard input

echo "$ACTUAL_SHA_VALUE  $FILENAME" | sha256sum -c

where $ACTUAL_SHA_VALUE is the shasum copied from the site and $FILENAME is the file name.

NOTE: There are two (2) spaces in between $ACTUAL_SHA_VALUE and $FILENAME. If this is not the case you will get an error of not having properly formatted SHA256 checksum lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment