aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-08-17 14:19:59 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-08-17 14:19:59 -0300
commit5ceceaffb35560b30f33a06b08a6622a2266c0d3 (patch)
treef96e85a8279130fcf3dc6acdc70bc33062794174 /share
parentd46f13b4683dcd456387e81b53017d2b672e778e (diff)
downloadkeyringer-5ceceaffb35560b30f33a06b08a6622a2266c0d3.tar.gz
keyringer-5ceceaffb35560b30f33a06b08a6622a2266c0d3.tar.bz2
Added support to encrypt from files
Diffstat (limited to 'share')
-rwxr-xr-xshare/keyringer/encrypt19
-rw-r--r--share/man/keyringer.1.mdwn4
2 files changed, 18 insertions, 5 deletions
diff --git a/share/keyringer/encrypt b/share/keyringer/encrypt
index 3680d0b..f35cdff 100755
--- a/share/keyringer/encrypt
+++ b/share/keyringer/encrypt
@@ -8,7 +8,18 @@ LIB="`dirname $0`/../../lib/keyringer/functions"
source "$LIB" || exit 1
# Aditional parameters
-keyringer_get_new_file "$2"
+if [ ! -z "$3" ]; then
+ UNENCRYPTED_FILE="$2"
+ keyringer_get_new_file "$3"
+
+ if [ ! -f "$UNENCRYPTED_FILE" ]; then
+ echo "Error: cannot encrypted $UNENCRYPTED_FILE: file not found."
+ exit 1
+ fi
+else
+ UNENCRYPTED_FILE="-"
+ keyringer_get_new_file "$2"
+fi
# Set recipients file
keyringer_set_recipients "$FILE"
@@ -18,10 +29,12 @@ mkdir -p "$KEYDIR/`dirname $FILE`"
if [ "$BASENAME" == "encrypt" ]; then
# Only display directions if we're running encrypt, not encrypt-batch
- echo "Type your message and finish your input with EOF (Ctrl-D)."
+ if [ "$UNENCRYPTED_FILE" == "-" ]; then
+ echo "Type your message and finish your input with EOF (Ctrl-D)."
+ fi
fi
-$GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") - > "$KEYDIR/$FILE"
+$GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") --yes --output "$KEYDIR/$FILE" $UNENCRYPTED_FILE
err="$?"
diff --git a/share/man/keyringer.1.mdwn b/share/man/keyringer.1.mdwn
index 23b8d85..14ae687 100644
--- a/share/man/keyringer.1.mdwn
+++ b/share/man/keyringer.1.mdwn
@@ -66,8 +66,8 @@ edit <*SECRET*>
: Edits a secret by temporarily decrypting it, opening the decrypted copy into *$EDITOR*
and then recrypting it again.
-encrypt <*SECRET*>
-: Encrypts content from standard input into *SECRET*.
+encrypt [*file*] <*SECRET*>
+: Encrypts content from standard input or *file* into *SECRET*.
encrypt-batch <*SECRET*>
: Encrypt content, batch mode.