Variable name reworking; laid foundation for GPG encryption (instead of OpenSSL)

This commit is contained in:
Jon-William Lewis
2016-01-25 17:20:05 -06:00
parent 908b93242c
commit 6a21731082
12 changed files with 180 additions and 102 deletions

View File

@@ -1,8 +1,18 @@
function encrypt(){
openssl enc -aes-256-cbc -salt -in "$TARGET" -out "$NOTE" -pass pass:"$ENC_KEY"
# This function, given a recipient, $PUBKEY; a file to encrypt, $TARGET; and an
# output file, "$NOTE", will encrypt $TARGET to $NOTE against $PUBKEY's private
# GPG key.
gpg -r "$PUBKEY" --encrypt-files "$TARGET" --output "$NOTE"
}
function decrypt(){
TARGET="$ROOTDIR"/tmp/"$RANDOM"
openssl enc -d -aes-256-cbc -in "$NOTE" -pass pass:"$ENC_KEY" > "$TARGET"
# This function, given a recipient, $PUBKEY; a file to decrypt, $TARGET; and an
# output file, "$NOTE", will decrpyt $TARGET to $NOTE against $PUBKEY's private
# GPG key.
if [ ! -d "$ROOT_DIR"/tmp ]; then mkdir "$ROOT_DIR"/tmp; fi
TARGET="$TMP_DIR/$RANDOM"
gpg -d "$NOTE" > "$TARGET"
}