Decrypting symmetrically encrypted text in Command Line (CL) results in error message?

Sin Trenton biggles.trenton at gmail.com
Wed Nov 27 12:35:51 CET 2013


Hello everyone,

I've tried to find info regarding this but no real luck so far. It was 
discussed in the thread "encryption/decryption without files", but I 
haven't found a reply there that covers 'symmetric decryption'.
And yes, I am aware of plaintext, shell, bash, etc.
These are generally short text snippets, which can be considered 
internal, not even confidential (I'm not familiar with the names of 
levels up to "Ultraviolet Top Secret", but this would barely reach "Just 
don't forget too many print outs on the tube" level. :) )
We use it mainly for small txt files stored in the cloud, some things 
sent over Google or stored temporarily in some docs at Google Drive, etc.

Anyway, I often use -ac in command line to encrypt these text snippets.
I write the text or message, finish with Ctrl+Z (We use Windows at 
work), and copy the encrypted text.

One thing I would like to do is the opposite, however, but I haven't 
figured out how to, yet.
If I want to decrypt a short text snippet, I have to

  1. copy the snippet
  2. paste it into a txt file
  3. save the file
  4. use "gpg -d file.txt"

(The text is then read in the CL window, I have no interest in this case 
to save the decrypted text, just read it and e.g. check a reference)

Is it possible to replace steps 2 and 3 by pasting in the text in the CL?

I've tried "gpg [Enter]", but I always get the message "decryption 
failed: bad key" as you can see below.
Everything below the encrypted message happened automatically when I 
pasted in the text first time, though next time it did wait for me to 
supply the passphrase, with same "bad key" result, however.

Note that the last line "-----END PGP MESSAGE-----" disappears. Also, 
the prompt does not return to the standard ">", until I have done a 
Ctrl+Z or Ctrl+C.

  >gpg
  gpg: Go ahead and type your message ...
  -----BEGIN PGP MESSAGE-----
  Version: GnuPG v1.4.15 (MingW32)

  jA0ECgMCpM [snip] zHEHXtFP3
  =uNdz
  gpg: TWOFISH encrypted data
  gpg: encrypted with 1 passphrase
  gpg: decryption failed: bad key

As I wrote in the subject line, this is when using symmetric encryption 
(as you can see), since we use that in these particular cases.
It does work with asymmetric encryption, though the workflow is a bit 
dodgy even there, I think? The END PGP MESSAGE line disappears here as 
well and the first failed attempt for the passphrase happened without my 
input too.

  >gpg
  gpg: Go ahead and type your message ...
  -----BEGIN PGP MESSAGE-----
  Version: GnuPG v1.4.15 (MingW32)

  hQIMA [snip] /HaL1
  =ZWgL

  You need a passphrase to unlock the secret key for
  user: "Sin Trenton"
  4096-bit RSA key, ID 0x0A0A0A0A0A0A0A0A, created 2010-01-01
           (subkey on main key ID 0x0A0A0A0A0A0A0A0A)

  gpg: Invalid passphrase; please try again ...

  You need a passphrase to unlock the secret key for
  user: "Sin Trenton"
  4096-bit RSA key, ID 0x0A0A0A0A0A0A0A0A, created 2010-01-01
           (subkey on main key ID 0x0A0A0A0A0A0A0A0A)

  gpg: encrypted with 4096-bit RSA key, ID 0x0A0A0A0A0A0A0A0A, created 
2010-01-01
        "Sin Trenton"


  ^Z (Ctrl+Z, my input)

     [The decrypted text appears here after my input]


  >

Thankful for any pointers or help.

Best regards,

Sin Trenton




More information about the Gnupg-users mailing list