12

I'm trying to encrypt something with gpg -a and return the result to standard out rather than a file. According to the manual, it should be sufficient to omit an --output flag, but that doesn't seem to be the case. When I don't specify an output file, gnupg assumes I'm outputting to [input-file].gpg rather than stdout.

Is there a way to have GPG do this, or am I going to have to have it encrypt to a temporary file and then cat it?

Inaimathi
  • 449
  • 2
  • 4
  • 14

4 Answers4

26

Just in case anyone still needs to do this, you can do it with

gpg -ac -o- infile

Setting the output filename to "-" sends the output to stdout.

repsilat
  • 261
  • 3
  • 2
10

Instead of passing the input file to gpg, use shell redirection to send the input file to gpg's stdin, e.g.:

gpg -ac < inputfile
rsaw
  • 786
  • 6
  • 8
4

If anybody else needs a better or more concise answer:

You can do gpg --output - with any other flags.

For the example above you can do gpg --armor --symmetric --output - file.txt or gpg -aco - file.txt

aghosh93
  • 41
  • 1
0

edit: sorry realised you wanted symmetric encryption

gpg -a -c prompt will come up for the password, after that type your message then press ctrl+d

gpg -a --encrypt -r [email protected]

then type message, when you're done press ctrl+d

leshow
  • 101
  • 1