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?

4 Answers 4

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
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.

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .