The PERL libraries have changed a little bit and getting PHP and PERL to mcrypt together can be confusing, so here is a current example;
PHP
===
<?php
$string = 'Some Secret thing I want to encrypt';
$iv = '12345678';
$passphrase = '8chrsLng';
$encryptedString = encryptString($string, $passphrase, $iv);
function encryptString($unencryptedText, $passphrase, $iv) {
$enc = mcrypt_encrypt(MCRYPT_BLOWFISH, $passphrase, $unencryptedText, MCRYPT_MODE_CBC, $iv);
return base64_encode($enc);
}
?>
PERL
====
$encryptedString = '7DjnpOXG+FrUaOuc8x6vyrkk3atSiAf425ly5KpG7lOYgwouw2UATw==';
$iv = '12345678';
$passphrase = '8chrsLng';
$string = &decryptPhpEncrypted $encryptedString, $passphrase, $iv;
# Expect: Some Secret thing I want to encrypt
sub decryptPhpEncrypted() {
my ($encryptedString, $passphrase, $iv) = @_;
my $keysize = length($passphrase);
use Crypt::CBC;
$cipher = Crypt::CBC->new( {'key' => $encryptedString,
'cipher'=> 'Blowfish',
'iv' => $iv,
'keysize' => $keysize,
'regenerate_key' => 0,
'padding' => 'null',
'prepend_iv' => 0});
return $cipher->decrypt($encryptedString);
}