Add simple shell scripts to en/de-crypt files.
This commit is contained in:
parent
a1cd643ca6
commit
24e821e93d
23
bin/decrypt
Executable file
23
bin/decrypt
Executable 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
26
bin/encrypt
Executable 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}
|
Loading…
Reference in a new issue