]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Added support to encrypt from files
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 17 Aug 2013 17:19:59 +0000 (14:19 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 17 Aug 2013 17:19:59 +0000 (14:19 -0300)
index.mdwn
share/keyringer/encrypt
share/man/keyringer.1.mdwn

index a9beecfbfa30dc87afeedc2aa64655297593cb85..9156fe9e724f1433c0778b6f6564a2dbfa02469d 100644 (file)
@@ -85,6 +85,10 @@ Encrypting a key
 
     keyringer <keyring> encrypt <file>
 
+Encrypting a key from a file
+
+    keyringer <keyring> encrypt <plaintext-file> <file>
+
 Decrypting a key (only to stdout)
 
     keyringer <keyring> decrypt <file>
index 3680d0b91f43beb763592354c3b20eac77723384..f35cdff1542be64df24605184815a76f8d43854e 100755 (executable)
@@ -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="$?"
 
index 23b8d85786ac6f0bf356d50de9f153ec9eda6125..14ae687815c00d81ed46fe1dd4f72dd6c58765ee 100644 (file)
@@ -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.