Created
October 11, 2017 04:43
-
-
Save s7ephen/23bab58dff8ac90a906a2216b8636285 to your computer and use it in GitHub Desktop.
Use the openssl binary/version on OSX to do symmetric crypto.
This file contains 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 | |
# Use the openssl binary/version on OSX to do symmetric crypto. | |
# [email protected] | |
if [ "$#" != "2" ] | |
then | |
echo "Usage: ghettocrypt.sh encrypt file_to_encrypt.zip" 1>&2 | |
echo " OR" 1>&2 | |
echo "ghettocrypt.sh decrypt file_to_decrypt.zip.enc" 1>&2 | |
exit 1 | |
fi | |
function die { | |
echo "Something is fucked up. I can't help you. I give up" 1>&2 | |
exit 1 | |
} | |
action=$1 | |
crypt_file=$2 | |
# attempt to do the crypto | |
if [ "${action}" == "encrypt" ] | |
then | |
echo "Please enter your password, then hit Enter: " 1>&2 | |
openssl aes-256-cbc -in "${crypt_file}" -out "${crypt_file}.enc" -pass stdin || die | |
echo "Your encrypted file written to ${crypt_file}.enc" | |
fi | |
if [ "${action}" == "decrypt" ] | |
then | |
echo "Please enter your password, then hit Enter: " 1>&2 | |
openssl aes-256-cbc -d -in "${crypt_file}" -out "${crypt_file}.decrypted" -pass stdin || die | |
echo "Your decrypted file written to ${crypt_file}.decrypted" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment