Click here to get back home

Crypt::RSA

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Crypt::RSA rjvennes 03-10-2007
---> Re: Crypt::RSA Peter J. Holzer03-11-2007
Posted by Mumia W. on March 13, 2007, 6:04 am
Please log in for more thread options


On 03/12/2007 11:28 AM, rjvennes@hotmail.com wrote:
> The CGI script only need to exist for a single process... nothing
> needs to be passed to another process.
>
> Using Mumia suggestion of:
>
> use Data::Dumper;
> $key->deserialize(String => Dumper($PrivateKey));
>
> didn't seem to work either. [...]

After looking at the source, I see that the deserialize method *returns*
a new key object that contains the required data:

my $newkey = $key->deserialize(String => [ $PrivateKey ] );
# use $newkey to decrypt the message.

The code above assumes that $PrivateKey is a string created with
$key->write(). Notice that the $PrivateKey must be enclosed within an
anonymous array. Notice that the documentation does not say this.

Here is a program that doesn't demonstrate using
Crypt::RSA::Key::Private very well. I get an error, "n is not a number,"
from this program, but I still hope it helps you some:

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Crypt::RSA;
use Crypt::RSA::Key::Private;
use File::Slurp;

my $PrivateKey = read_file('key.private');
my $message = read_file('cypher.data');

my $rsa = new Crypt::RSA;
my $nokey = Crypt::RSA::Key::Private->new;
my $privkey = $nokey->deserialize(String => [$PrivateKey]);
my $plaintext;

$plaintext = $rsa->decrypt(
Cyphertext => $message,
Key => $privkey,
Armour => 1,
) or die $rsa->errstr;

print $plaintext;

__END__


Similar ThreadsPosted
Crypt::DH Crypt::Random install problem May 9, 2005, 5:25 am
Crypt::Tea becomes Crypt::Tea_JS January 17, 2005, 1:14 pm
Crypt::RC5 128 April 5, 2006, 10:31 am
RFC: Crypt::Skip32 [try 3] September 24, 2007, 12:51 am
(ANNOUNCE) Crypt::FileHandle October 24, 2004, 12:08 am
Des::Crypt Will not Compile On Solaris 8 Using GCC December 7, 2005, 2:58 pm
Crypt::SSLeay + OpenSSL 0.9.8 July 21, 2006, 5:31 am
Crypt::SSLEay for Windows March 7, 2007, 1:08 am
Crypt:DES make problem on Solaris 9 March 10, 2005, 12:39 pm
Crypt:DES make problem on Solaris 9 March 10, 2005, 12:52 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap