How encrypt data/text stream instead of a file?

David Shaw dshaw at
Thu Dec 18 19:01:48 CET 2008

On Thu, Dec 18, 2008 at 09:49:41AM -0800, don rhummy wrote:
> OK, so I need to put the data into the out stream. Can you give some sample code from C doing this? I'm not 100% clear on the order, etc of calling gpg and sending the data to "out." Thanks!

I don't want to do a full pipe/fork/exec/dup2 tutorial here (it's the
GnuPG list after all), but read this:

Or try "popen" (and add some error checking):

  FILE *my_gpg_stream;

  my_gpg_stream=popen("gpg -o - -r whoever -e the-file-to-encrypt ..etc...","r");

 (now read from "my_gpg_stream" until you see EOF).



More information about the Gnupg-users mailing list