Question regarding encrypt/decrypt
Posted: Mon Feb 16, 2004 2:23 pm
I have an old Perl script that someone wrote that I am trying to convert to PHP. I am having trouble with the decryption portion of the script as I am fairly new to PHP and especially encryption.
Here is the original Perl script that works:
And here is my php code that I got from looking through the manual and trying to decipher what I'm supposed to do.
The errors I'm getting are as follows:
Warning: mcrypt_generic_init(): Key size too large; supplied length: 24, max: 8 in /home/dd2000_stage/control/view_order.php on line 105
Fatal error: Call to undefined function: mycrpt_generic_deinit() in /home/dd2000_stage/control/view_order.php on line 108
Any help or nudge in the right direction would be greatly appreciated. I looked through the manual, but I'm still pretty darn lost. Thanks.
Here is the original Perl script that works:
Code: Select all
$CCNumber='';
if($header_dataї8] ne '') {
my $mcrypt_module=Mcrypt::mcrypt_load(Mcrypt::3DES,'',Mcrypt::CBC,'');
my $CCIV=decode_base64($header_dataї8]);
my $CCKey=substr(md5_hex($header_dataї2].$header_dataї3]),0,24);
$CCNumber=decode_base64($header_dataї6]);
Mcrypt::mcrypt_init($mcrypt_module,$CCKey,$CCIV);
$CCNumber=Mcrypt::mcrypt_decrypt($mcrypt_module,$CCNumber);
Mcrypt::mcrypt_end($mcrypt_module);
}
else {
$header_dataї6]=~tr/0-9//cd;
$CCNumber=$header_dataї6];
}And here is my php code that I got from looking through the manual and trying to decipher what I'm supposed to do.
Code: Select all
<?php
$CCNumber = ''; #line 96
if ($order_data[8] != '') {
$mcrypt_module = mcrypt_module_open(MCRYPT_DES, '',MCRYPT_MODE_ECB, '');
$CCIV = base64_decode($order_data[8]);
$CCKey = substr(md5($order_data[2].$order_data[3]),0,24);
$CCNumber = base64_decode($order_data[6]);
mcrypt_generic_init($mcrypt_module,$CCKey,$CCIV); #line 105
$CCNumber = mdecrypt_generic($mcrypt_module,$CCNumber);
mycrpt_generic_deinit($mcrypt_module); #line 108
mcrypt_module_close($mcrypt_module);
}
?>Warning: mcrypt_generic_init(): Key size too large; supplied length: 24, max: 8 in /home/dd2000_stage/control/view_order.php on line 105
Fatal error: Call to undefined function: mycrpt_generic_deinit() in /home/dd2000_stage/control/view_order.php on line 108
Any help or nudge in the right direction would be greatly appreciated. I looked through the manual, but I'm still pretty darn lost. Thanks.