OK, a wierd title, but I couldn't think of anything else.
Here's what I did after I installed Crypt::RSA.

Had a look at the author's tutorial at perl's own website.
Followed suit and prepared this code:
#!/usr/bin/perl use strict; use Crypt::RSA; my $message="string"; my $rsa = new Crypt::RSA; my ($public, $private) = $rsa->keygen( Size => 64 ); print "My Public key is: $public ", $public->serialize(); print "My Private key is: $private", $private->serialize(); my $c = $rsa->encrypt( Message => $message, Key => $public, ) or warn +"$!\n"; print "My cipher text is: $c\n"; my $nmessage = $rsa->decrypt( Ciphertext => $c, Key => $private, ); print "My plain text is: $nmessage\n";
Modified the RSA.pm to print certain messages in the enrypt subroutine:
.... ...... .... sub encrypt { my ($self, %params) = @_; my $plaintext = $params{Message} || $params{Plaintext}; my $key = $params{Key}; print "\n$plaintext\n$key\n"; return $self->error ($key->errstr, \%params, $key, \$plaintext) unless $key->check(); print "\nAfter self error\n"; my $blocksize = blocksize ( $$self{es}->encryptblock (Key => $key) +, length($plaintext) ); print "\nAfter block size\n"; return $self->error("Message too long.", \$key, \%params) if $bloc +ksize <= 0; print "\nAfter self error\n"; my $cyphertext; .... ....
Executed the code and got the following message:
My Public key is: Crypt::RSA::Key::Public=HASH(0x8132390) $VAR1 = bles +s( { 'e' => 65537, 'n' => '10270622025769038677', 'Version' => '1.91' }, 'Crypt::RSA::Key::Public' ); My Private key is: Crypt::RSA::Key::Private=HASH(0x8132378)$VAR1 = ble +ss( { 'Version' => '1.91', 'Checked' => 0, 'private' => { '_phi' => '10270622019208864620', '_n' => '10270622025769038677', '_q' => '2581267387', '_p' => '3978906671', '_u' => '564982676', '_dp' => '2208958913', '_dq' => '2285751125', '_d' => '4317024349041710693', '_e' => '65537' }, 'Cipher' => 'Blowfish' }, 'Crypt::RSA::Key::Private' ); string Crypt::RSA::Key::Public=HASH(0x8132390) After self error Can't call method "encryptblock" on an undefined value at /usr/lib/per +l5/site_perl/5.8.0/Crypt/RSA.pm line 98.
Haven't been able to figure out why the "blocksize" method is failing.

Your thoughts?

Thanks,
Rupesh.

Edited by Arunbear: Changed title from 'The "R", the "S" and the "A"...', as per Monastery guidelines


In reply to Crypt::RSA dies: Can't call method "encryptblock" on an undefined value by rupesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.