CPAN::Forum
Crypt-OpenPGP - Re: Help with Crypt::OpenPGP
| Posted on Mon Feb 21 22:03:39 2005 by ata in response to 139 (See the whole thread of 6) |
| Re: Help with Crypt::OpenPGP |
|
OK, as usual when all else fails ignore the documentation and look at an example. This works. BTW, the process must of course have read access to the keyrings.
use strict;
use CGI;
use CGI::Carp 'fatalsToBrowser';
$CGI::POST_MAX= 10*1048; # max 10K byte posts
$CGI::DISABLE_UPLOADS = 1; # no upload
use Crypt::OpenPGP;
use Crypt::OpenPGP::KeyRing;
my $mailprog = "/usr/sbin/sendmail";
my $recipient = "test\@mydomain.com";
my $key_id = "05C1F245";
my $ring_file = '/home/mpo/.gnupg/pubring.gpg';
my $ring = Crypt::OpenPGP::KeyRing->new( Filename => $ring_file )
or die "Error: Crypt::OpenPGP::KeyRing->errstr";
my $pgp = Crypt::OpenPGP->new(PubRing => $ring);
my $ciphertext = $pgp->encrypt(
Data => "test 1234",
Recipients => $key_id,
Armour => 1,
);
print $pgp->errstr;
open (MAIL,"|$mailprog $recipient") || die "Unable to send email to $recipient.";
print MAIL "$ciphertext\n";
close (MAIL);
exit;
|
| Direct Responses: 2614 | Write a response |
(3)
]