How encrypt data/text stream instead of a file?

David Shaw dshaw at jabberwocky.com
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:

  http://www.cs.uleth.ca/~holzmann/C/system/pipeforkexec.html

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

  pclose(my_gpg_stream);

David



More information about the Gnupg-users mailing list