My perl script is not to decrypt a AES encrypted string in php
I think I am missing something here , Are there any sample scripts available to decrypt in perl with an IV
This is the Encrypt script in php
<?php
$encryption_key = base64_decode('OhjsqEflVL1GNteBIgpD1ngMvS3vVicAkfTyerJjr/c=');
$iv = "1234567812345678";
$data = "PLAIN TEXT";
$encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, OPENSSL_RAW_DATA, $iv);
print "Encrypted string = <".base64_encode($encrypted).">\n";
$decrypted = openssl_decrypt($encrypted,'aes-256-cbc', $encryption_key, OPENSSL_RAW_DATA , $iv);
print "DECRYPTED DATA=<$decrypted>\n";
?>
This is the decrypt script in perl
use Crypt::CBC;
use Crypt::Cipher::AES;
use MIME::Base64 qw(decode_base64);
use strict;
my $key=decode_base64('OhjsqEflVL1GNteBIgpD1ngMvS3vVicAkfTyerJjr/c=')
my $iv = "1234567812345678";
$iv=undef;
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::AES', -key=>$key, -iv=>$iv );
my $plaintext = $cbc->decrypt(decode_base64('sR9aVLpjHgpbM7Kw8hb7Ig=='));
print "$plaintext\n";