Last active
December 29, 2015 02:18
-
-
Save thanthese/417d5103c1a61002ae45 to your computer and use it in GitHub Desktop.
Transparently edit an encrypted file.
This file contains hidden or 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 | |
# Transparently edit an encrypted file. | |
# | |
# This system isn't intended to be perfectly secure but is rather intended to | |
# let me edit encrypted files on dropbox securely. | |
# | |
# Inspiration: https://gist.github.com/jakeonfire/9bf7ff1b08ed2c76fefc | |
set -e | |
set -o pipefail | |
if [ $# != 1 ]; then | |
echo "usage: $ edit-gpg filename" | |
exit 1 | |
fi | |
tempfile=$(mktemp -t edit-gpg) | |
function cleanup { | |
rm $tempfile | |
# echo "Deleted: $tempfile" | |
} | |
trap cleanup EXIT | |
file=$1 | |
read -sp "Password for '$(basename $file)': " passphrase; echo | |
gpg -qd --passphrase $passphrase -o $tempfile --yes $file | |
vim -n -i NONE -c "set filetype=txt" $tempfile | |
gpg -qca --passphrase $passphrase --cipher-algo AES256 -o $file --yes $tempfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment