need example of passing clear text to gpg from another app without using temp files

Dave (My-IOP) dave at
Tue Feb 12 02:00:48 CET 2008

On Feb 11, 2008 6:57 PM, Luke Powell <luke at> wrote:

> On 02/11/2008 03:30 PM, Dave (My-IOP) wrote:
> > Hi,
> > I want to pass clear text from a text editor to gpg for encryption (on a
> > Linux system). Currently it is being done by writing the clear text to a
> > temp file and having gpg read that temp file and then write it back out
> > as an encrypted file. Obviously, it would be much better to avoid ever
> > writing the clear text to disk.
> >
> > How can I pass the clear text to gpg via a pipe and avoid using the temp
> > file on disk?
> >
> > I am a noob (to both Linux and gpg), so a very clear example is greatly
> > appreciated.
> >
> Well, it really depends a lot on your text editor. I use Vim, so my
> command is
> gg!Ggpg -ae -r luke at
> That goes to the beginning of the file and filters all the text through
> the the process gpg -ae -r luke at
> As for how to do it under Emacs, I'm sure another of these fine people
> can help. Also, if security is important, you'll want to make sure that
> any hard drive writes or backups are disabled. In Vim, you'll want to
> turn off the scratch file.
> Hope that helps,
> Luke Powell

Hi Luke,
Thanks for the feedback. I'm using Cream, which is based on Vim. It is
similar, but the script commands are written with a different style --
everything is a function, for example. (I'm no expert on it by any means --
just a noob.)

The problem I face is that Cream apparently has to pass the clear text to be
encrypted as a command argument when only a portion of the text is being
encrypted.  For example, if I have the following text:

Line one.
Line two.
Last line.

Say I want to encrypt line two in place in the document. The result should
look like this:

Line one.
Version: GnuPG v1.4.6 (GNU/Linux)


Last line.

I do not know how to get Cream/Vim to pass the register contents that hold
the selected text to gpg via a pipe (without a temp file being used). I now
know how to do this sequence of eventgs on the command line, but not in

Using temp files, the code looks something like this:

" cut selection into register
    normal "xx
" encrypt
    call writefile([@x], tmpfile)
 " command
        silent execute 'silent! !gpg -ae --default-recipient-self -o "' .
tmpfile . '.gpg" "' . tmpfile . '"'

The main issue is how to avoid using a temp file and that's where I'm stuck.
I have some help from someone who knows Cream well, but he doesn't know gpg
well. (And unfortunately, I don't know either of them well!)


P.S. Should I reply to all when replying to this list?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20080211/24ac3971/attachment.htm>

More information about the Gnupg-users mailing list