jeteve has asked for the wisdom of the Perl Monks concerning the following question:
I'm playing with Crypt::OpenPGP and I think I'm starting to loose my sanity. No matter how hard I try, I always end up by having some error from the PARI lib when I decrypt.
Here's my test script (shamelessly taken from this site #522597):
#!/usr/bin/perl use strict; use warnings; # generate public/private Crypt::OpenPGP keys. # encrypt some data # decrypt some data use Crypt::OpenPGP; my $size = 1024; my $ident = 'Me <me@example.com>'; my $pass = 'my passphrase'; my $public_file = 'public.pgp'; my $private_file = 'private.pgp'; my $keychain = Crypt::OpenPGP->new; my ($public, $private) = $keychain->keygen ( Type => 'RSA', Size => $size, Identity => $ident, Passphrase => $pass, Verbosity => 1, ) or die $keychain->errstr( +); my $public_str = $public->save; my $private_str = $private->save; print "Public encrypting_key: ".$public->encrypting_key ."\n"; print "Private encrypting_key: ".$private->encrypting_key ."\n"; open( PUB, '>', $public_file ) or die $!; print PUB $public_str; close(PUB); open( PRIV, '>', $private_file ) or die $!; print PRIV $private_str; close(PRIV); my $pgp = Crypt::OpenPGP->new( PubRing => $public_file ); my $cyphertext = $pgp->encrypt ( Data => 'Encrypt This', Recipients => $ident, Armour => 1, ) || die $pgp->errstr(); print $cyphertext; $pgp = new Crypt::OpenPGP( SecRing => $private_file ); my $plaintext = $pgp->decrypt ( Data => $cyphertext, Passphrase => $pass, ) || die $pgp->errstr(); print "plaintext: $plaintext\n";
It invariably ends with:
PARI: *** unexpected character:
^-
Note that I've got the latest version of Crypt::OpenPGP from github, and that all the unit test pass very happily.
I must be going something very wrong. Thanks in advance for your help.
-- Jerome Eteve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Crypt OpenPGP Brain twister
by Khen1950fx (Canon) on Jun 21, 2011 at 17:24 UTC | |
by Anonymous Monk on Jun 22, 2011 at 07:23 UTC | |
by Anonymous Monk on Aug 14, 2012 at 20:34 UTC | |
by Anonymous Monk on Aug 17, 2012 at 11:10 UTC | |
by Anonymous Monk on Aug 14, 2012 at 20:39 UTC | |
by Anonymous Monk on Feb 02, 2014 at 18:30 UTC | |
by Anonymous Monk on Jul 31, 2019 at 03:21 UTC | |
|
Re: Crypt OpenPGP Brain twister
by Anonymous Monk on Jun 21, 2011 at 01:13 UTC | |
by jeteve (Pilgrim) on Jun 21, 2011 at 08:39 UTC | |
by Anonymous Monk on Jun 21, 2011 at 10:04 UTC | |
by jeteve (Pilgrim) on Jun 21, 2011 at 12:37 UTC |