Using GPG to encrypt raw data from a Perl Script

Matthias Urlichs smurf@noris.de
Fri Feb 23 09:04:05 2001


Hi,

Ton Sistos:

> $passphrase .= "\n" if $passphrase !~ /\n$/; # add a LF if it is not
> already there
> if (eval { $pid = open2(*README, *WRITEME, 'gpg --passphrase-fd
> 0 --symmetric'); }) {
You shouldn't use stdin as the passphrase FD if you also use it for the data to be encrypted. And if the data in question is too large to fit into the pipe buffers, the above exercise _will_ fail. You need to fork twice, instead: once for executing gpg and once for feeding the input data to it. -- Matthias Urlichs | noris network AG | http://smurf.noris.de/ -- I have not touched that module! -- typical programmer's remark when hearing about a bug