Dear monks

Using the doc from cpan I was able to construct the following script:
#! /usr/bin/perl use Crypt::OpenSSL::Random; use Crypt::OpenSSL::RSA; use Data::Dumper ; my $rsa = Crypt::OpenSSL::RSA->generate_key(1024); # or print "private key is:\n", $rsa->get_private_key_string(); print "public key (in PKCS1 format) is:\n", $rsa->get_public_key_string(); print "public key (in X509 format) is:\n", $rsa->get_public_key_x509_string(); #$rsa_priv->use_md5_hash(); # use_sha1_hash is the default #$signature = $rsa_priv->sign($plaintext); #print "Signed correctly\n" if ($rsa->verify($plaintext, #$signature)) +;
So, I've generated $rsa, which can give me a private/public key as a string. The question is, how do I encrypt and decrypt using ?

Cheers
LuCa

UPDATE: I solved it with RSA:
my $rsa = Crypt::OpenSSL::RSA->generate_key(2048); # or my $rsa_priv = Crypt::OpenSSL::RSA->new_private_key($rsa->get_private_ +key_string() ); my $rsa_pub = Crypt::OpenSSL::RSA->new_public_key( $rsa->get_public_ke +y_string() ); my $ciphertext = $rsa_pub->encrypt($plaintext) ;

In reply to encrypt and decrypt with crypt::OpenSSL::RSA by jeanluca

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.