how encrypt data/text stream instead of a file?

Doc Webb DocWebb at
Sat Jun 25 20:03:34 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.
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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20110625/68bbfafd/attachment.htm>

More information about the Gnupg-users mailing list