I'm trying to generate a public and private key with passphrase protection in Perl but I haven't found anything useful.
Until now I have found this link http://search.cpan.org/~vipul/Crypt-RSA-1.57/lib/Crypt/RSA.pm which seems very promising. However, I can decrypt my message without any passphrase although I have created them with a passphrase.
The other link was this http://www.perlmonks.org/?node_id=903458 but when I create my keys (in order to store them in the DB) I still can decrypt without using a passphrase.
In summary, I need a library which allows me to encrypt text using private keys using a passphrase for both.
Thanks for your help!
PD: Please no PGP encryption.
UPDATE
Here is a pice of code that does not work as expected:
use strict;
use warnings;
use Data::Dumper;
use 5.010;
use Crypt::RSA;
my $rsa = new Crypt::RSA;
my ($master_public, $master_private) = $rsa->keygen(
Identity => "Someone",
Size => 1024,
Password => "this is a password or passphare",
) or die $rsa->errstr();
my $cyphertext = $rsa->encrypt (
Message => "My Message that I want to encrypt",
Key => $master_public,
Armour => 1,
) or die $rsa->errstr();
my $text = $rsa->decrypt (
Cyphertext => $cyphertext,
Key => $master_private,
Armour => 1,
# Here I expect to add the user's passphrase
) or die $rsa->errstr();
say $text;