Add simple shell scripts to en/de-crypt files.

This commit is contained in:
Scott Wallace 2016-09-26 19:38:12 +01:00
parent a1cd643ca6
commit 24e821e93d
2 changed files with 49 additions and 0 deletions

23
bin/decrypt Executable file
View file

@ -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}

26
bin/encrypt Executable file
View file

@ -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}