diff --git a/bin/decrypt b/bin/decrypt new file mode 100755 index 0000000..a3f01ba --- /dev/null +++ b/bin/decrypt @@ -0,0 +1,23 @@ +#!/bin/bash + +KEY_KEY=~/.ssh/scott@wallace.sh +KEY=$(mktemp) + +if [ -f "${1}.enc" ]; then + INPUT=${1} +else + echo "ERROR: Filenme not valid" + exit 1 +fi + +function cleanup() { + rm -f ${KEY} +} + +trap cleanup EXIT + +# Decrypr key +openssl rsautl -decrypt -inkey ${KEY_KEY} -out ${KEY} -in ${INPUT}.key + +# Decrypt file +openssl enc -d -aes-256-cbc -salt -out ${INPUT} -in ${INPUT}.enc -pass file:${KEY} diff --git a/bin/encrypt b/bin/encrypt new file mode 100755 index 0000000..bcd6b35 --- /dev/null +++ b/bin/encrypt @@ -0,0 +1,26 @@ +#!/bin/bash + +KEY_KEY=~/.ssh/scott@wallace.sh +KEY=$(mktemp) + +if [ -f "${1}" ]; then + INPUT=${1} +else + echo "ERROR: Filenme not valid" + exit 1 +fi + +function cleanup() { + rm -f ${KEY} +} + +trap cleanup EXIT + +# Generate key +openssl rand -base64 256 > ${KEY} + +# Encrypt key +openssl rsautl -encrypt -inkey ${KEY_KEY} -in ${KEY} -out ${INPUT}.key + +# Encrypt file +openssl enc -aes-256-cbc -salt -in ${INPUT} -out ${INPUT}.enc -pass file:${KEY}