#!/bin/bash KEYFILE=.encryption_key KEYFILE=$HOME/$KEYFILE if [ $# -eq 0 ] then echo "Decrypt a file using a keyfile at $KEYFILE and store it to the filename without the .enc.txt ending." echo "Usage: $0 ". exit 1; fi if [ ! -f "$KEYFILE" ]; then echo "$KEYFILE does not exist. Please create that first with the decryption key you want to use." exit 1 fi PASSWORD=$(cat "$KEYFILE") INPUT_FILE=$1 openssl aes-256-cbc -md sha256 -d -a -in ${INPUT_FILE} -out ${INPUT_FILE%%.enc.txt} -pass pass:${PASSWORD} echo "Decrypted '$INPUT_FILE' using the key at '$KEYFILE'." echo "Wrote output to '${INPUT_FILE%%.enc.txt}'.";