how encrypt data/text stream instead of a file?
jerome at jeromebaum.com
Mon Jun 27 14:48:06 CEST 2011
> Sorry if I am out of line contacting you by email but I didn't see any other
> way to ask a question.
That's what this mailing list is for.
> I am a newbie Perl programmer and I want to pipe plain text to GPG and have
> it return the text encrypted.
> I have read quite a few articles and came up with this chunk of code on my
> own BUT it doesn't work and I was wondering if you can tell me what I am
> doing wrong...
> my $public_key = "nameofpublickey";
> my $plain_text = "this is a test message";
> my $gpg_command = '/usr/local/bin/gpg';
> open (GPGCOMMAND, "|$gpg_command");
> my $encrypted_text = print GPGCOMMAND $plain_text | '$gpg_command -ea -r
> close (GPGCOMMAND);
> print "encrypted text=$encrypted_text";
> It prints: encrypted text=1
> What am I doing wrong?
Seems like a Perl-related issue to me, not a GnuPG-related issue.
Basically $encrypted_text is not, as you intended, the output from the
gpg -- I think it's the output from print, in this case 1 ("true") for
"yes, we managed to pipe this into gpg".
I suggest consulting with the appropriate Perl mailing list for how to
pipe into a command and get the output. Also consider "--batch" and
related options, see <http://man.cx/gpg>.
email jerome at jeromebaum.com
PGP: A0E4 B2D4 94E6 20EE 85BA E45B 63E4 2BD8 C58C 753A
PGP: 2C23 EBFF DF1A 840D 2351 F5F5 F25B A03F 2152 36DA
Q: Why is this email five sentences or less?
More information about the Gnupg-users