use Crypt::OpenPGP; my $pgp = Crypt::OpenPGP->new( PubRing => $pubring); my $ciphertext = $pgp->encrypt( Data => $data, Recipients => $key_id, Armour => 1, );