IBM AIX: Calculate the SHA256 hashes of a directory without sha256sum

echo '#! /usr/bin/ksh\necho `cat $1 | openssl dgst -sha256` $1' > sslsha256; chmod +x sslsha256; find directory -type f -exec ./sslsha256 \{\} \;
This command is for producing GNU sha256sum-compatible hashes on UNIX systems that don't have sha256sum but do have OpenSSL, such as stock IBM AIX. 1.- Saves a wrapper script for UNIX find that does the following: A.- Feeds a file to openssl on SHA256 hash calculation mode B.- Echoes the output followed by the filename 2.- Makes the file executable 3.- Runs find on a directory, only processing files, and running on each one the wrapper script that calculates SHA256 hashes Pending is figuring out how to verify a sha256sum file on a similar environment.
Sample Output
6e94b0b7fc2805ad558f8039ed038a6272f61846eaa5f4931abd826193c78b83 cognos-installers/TM1-952-AIX/952_FP2_aix.tar.gz
c9d0f04ad6f86482bf4c41ba7a303e0d8a0e8c96c9c9492bc518d2a2bc0166c7 cognos-installers/TM1-952-AIX/952_FP2_HF6_aix.tar.gz
46ede3255abff4e356b002a9cd12df259275a15910768997bfbbae3c637b7f32 cognos-installers/TM1-952-windows/TM1_9.5.2_Windows_x64.7z
92faf20dd3ff25d2c8d94308f03fd8477d0980d6b740baa96a8e79b30b49456f cognos-installers/TM1-952-windows/TM1_Workflow_9.5.2_Windows_x64.7z
630a66a1f7cc3044f370cec730820d73d66cb284a2a09e197c00f82d6900d932 cognos-installers/cognos-BI-102/cognos-FM/fm_10.2_win_ml.tar.xz

2013-09-18 17:37:50

These Might Interest You

  • A bitcoin "brainwallet" is a secret passphrase you carry in your brain. The Bitcoin Brainwallet Exponent Calculator is the second of three functions needed to calculate a bitcoin PRIVATE key. Roughly, checksum is the first 8 hex digits of sha256(sha256(0x80+sha256(passphrase))) Note that this is a bash function, which means you have to type its name to invoke it Show Sample Output

    function brainwallet_checksum () { (o='openssl sha256 -binary'; p='printf';($p %b "\x80";$p %s "$1"|$o)|$o|sha256sum|cut -b1-8); }
    nixnax · 2014-02-18 02:07:02 0
  • This command is used to verify a sha256sum-formatted file hash list on IBM AIX or any other UNIX-like OS that has openssl but doesn't have sha256sum by default. Steps: 1: Save to the filesystem a script that: A: Receives as arguments the two parts of one line of a sha256sum listing B: Feeds a file into openssl on SHA256 standard input hash calculation mode, and saves the result C: Compares the calculated hash against the one received as argument D: Outputs the result in a sha256sum-like format 2: Make the script runnable 3: Feed the sha256sum listing to xargs, running the aforementioned script and passing 2 arguments at a time Show Sample Output

    echo '#! /usr/bin/ksh\ncat $2 | openssl dgst -sha256 | read hashish; if [[ $hashish = $1 ]]; then echo $2: OK; else echo $2: FAILED; fi;' > shacheck; chmod +x shacheck; cat hashishes.sha256 | xargs -n 2 ./shacheck;
    RAKK · 2013-09-18 21:51:20 2

  • -2
    find . -type f -name '*' -exec md5sum '{}' + > hashes.txt
    phatpat · 2015-04-27 14:01:35 1
  • A bitcoin "brainwallet" is a secret passphrase you carry in your brain. The Bitcoin Brainwallet Exponent Calculator is one of three functions needed to calculate the bitcoin PRIVATE key. Roughly, the formula is exponent = sha256 (passphrase) Note that this is a bash function, which means you have to type its name to invoke it. You can check the accuracy of the results here Show Sample Output

    function brainwallet_exponent () { printf %s "$1"|sha256sum|head -c 64; }
    nixnax · 2014-02-18 01:49:09 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: