I think I've isolated the problem: when I ran the script as myself, the script was using my personal keyring, not the one I'm passing it. For some reason, the keyring I'm trying to create in the program isn't working. I've reduced the problem to this script; if I can get this to work, I believe I can make the larger program run as well.
#! /usr/bin/perl
use strict;
use Crypt::OpenPGP;
my $gpg = Crypt::OpenPGP->new
or die "Cannot create Crypt object: $!";
my $ring = Crypt::OpenPGP::KeyRing->new( Data => \*DATA )
or die "Cannot create keyring: $!";
my $plaintext = 'Foobar!';
my $cipher = $gpg->encrypt(
Compat => 'GnuPG',
PubRing => $ring,
Data => $plaintext,
Armour => 1,
Recipients => 'douggorley@shaw.ca'
) or die "Cannot encrypt text: " . $gpg->errstr;
print "$cipher";
__DATA__
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.2.2 (GNU/Linux)
mQGiBDwTwfQRBADH+C+xkm3V3rFywQJw9IwkbNKifRxn47GSZEOOTxNn6IupqqGi
lO7BndliHsBQEqqalQchv6Ly8Djxl0aeS5MweCT1qrlrtkMtbqYtDcyp10x2iTcC
4MA5dU1/P/TdhEQQSAgSFbt3qE2ZnK3wsai2CdEFR47xAKG6NKwmMPeUAwCg+61C
gaMddxI+5/kzoCGomqGmcI8D/2qculnwGTeNyDH5EKJnb0w2Cjb7jmxe8RtAOKEx
3hApV18Ng5dWiEuId8TmAYoQiHyC09vv9L0lADysTNrzfH8ozXZwXJlcIYFg/Doi
jtUleX0mmZVSUkrJJ+rybT8jcfcWso2wa/igLjTyWHwXqPdkLf3zDOM8V1KJO1zj
Og3BBAC5j0iM3vKvkU0KXt9A2i+0Pz+xPIrUc3XUVVHntq9nhOPOhbckHF81tfTu
UnKFPQhiHmYFSoqhwMuPvMGvq3URs29WsCUGjX1gcoMkinOkAeOLQwwNh3MxMAri
d0GFaeQPUK0V4uG5HDRG6Ggs95mfF3TjO3bcjikR+xzEd+cIv7QgRG91ZyBHb3Js
ZXkgPGRvdWdnb3JsZXlAc2hhdy5jYT6IWgQTEQIAGgULBwoDBAMVAwIDFgIBAheA
AhkBBQI8E8H1AAoJEMWpVBWiIVWb8OcAoPQ+2Rz3aQ6nsVBNFGRbN6XBHhoOAJ4v
TWlEp4vz3/seWpJu8Eusd9eH0ohGBBARAgAGBQI+XGA+AAoJEIIiaBYBnUdP6X8A
ni7yhBPc37MatJad9tKO1m/FKXv/AKCHC0hIIr0rSPl5oWt265Cit228KrkBDQQ8
E8H6EAQAhSB8LOS83dcRvxpq8k3y9SfzthnQyDtJRi/6qaE7+LCSPzx4SDfxP1Sn
r/ScPceqTP54GR51nYLTv9abm75SIbcgkwUQx2U0q5XM3UjZB2ZJxLQ1bOxhFJpn
F8PX9PtDm77e3zitCRdoBlXyKcKCnDKSAhp2B9hhD9eOj6i9ah8AAwcD/itF9KhK
sUr/SD33ToPJ216aTx9aQ2iyWMcQ4hEaTq0bLN8UOBLvwFYglUdA1wUjrEUKK9QC
ptfb5+/CibNvjTuP6M+087OmX/BFKLIhfO9oQlp3RV1u9futp1tzTlRo2F0uI1YV
mAIHNuildXCSCuTEkctQlujqMSJ5E1B1dYr3iEYEGBECAAYFAjwTwfoACgkQxalU
FaIhVZsCNgCfWHmXo/me0717bsT38c55Uqfrng0AoLTOcDzWdHln4MhLBOQ+RVN6
u0sd
=NtKC
-----END PGP PUBLIC KEY BLOCK-----
_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|