I would like to know how to return the same values for a 3DES encription in perl and php. The PHP code is the following:
$bytes = array(0,0,0,0,0,0,0,0);
$iv = implode(array_map("chr", $bytes));
$ciphertext = mcrypt_encrypt(MCRYPT_3DES, base64_decode('Mk9m98IfEblmPfrpsawt7BmxObt98Jev'), '0000001920', MCRYPT_MODE_CBC, $iv);
echo base64_encode($ciphertext);
The result is: "A/VCTXA6q/x/emW0zzlSDg=="
The perl code is:
use Crypt::CBC;
$cipher = Crypt::CBC->new( -key => decode_base64('Mk9m98IfEblmPfrpsawt7BmxObt98Jev'),
-cipher => 'DES_EDE3',
-iv => pack("H*","0000000000000000"),
-literal_key => 1,
-header => 'none'
);
$ciphertext = $cipher->encrypt("0000001920");
print encode_base64($ciphertext, '');
The result is: "A/VCTXA6q/y9g7ypgqlWIg=="
The results are very similar, what I'm doing wrong in my perl code?