Hi there,
I'm new on encryption decryption, so if any one can help that would be very much appreciated
I need to decrypt a file downloaded from a web service, I have received a RSA Private key file and a certificate file.
I have installed the Crypt::RSA module and read the doco, but everything I've tried doesn't seems to work.
Apart from decrypt the file I still neeed to unzip it, but I would be very happy if anyone could give me some directions on how to import the key and how to decrypt the file.
I have tried the following code but I get the following message on the desirealise line
Can't use string ("$VAR1 = 'MIICXgIBAAKBgQCq5UIK++G") as an ARRAY ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.8/Crypt/RSA/Key/Private.pm line 212.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Crypt::RSA;
use Crypt::RSA::Key::Private;
my $PrivateKey;
my $message;
open(INPUT,"<ecryptedfile") ||
die "Can't inputecryptedfile $!";
binmode(INPUT);
$message = join(qq{}, <INPUT>);
close INPUT;
#print "The cyphertext is:\n$cypher\n\n";
# Load the private key into memory
open (INPUT1, 'keys/6312.KEY') || die "can't open keys/6312.KEY:$!";
binmode(INPUT1);
while (<INPUT1>)
{
print $_;
chomp;
$PrivateKey .= $_;
}
my @PrivateKey=<INPUT1>;
close(INPUT1) || die "can't close key: $!";
#print $PrivateKey;
my $rsa = new Crypt::RSA;
my $privkey = Crypt::RSA::Key::Private->new;
my $privkey = $nokey->serialize(String => [$PrivateKey]);
my $plaintext;
$plaintext = $rsa->decrypt(
Cyphertext => $message,
Key => $privkey,
Armour => 1,
) or die $rsa->errstr;
print $plaintext;