I have migrated from PHP 5.x to PHP 7.3 and I am unable to understand how to fix this function I use extensively:
function md5_decrypt($enc_text, $salt, $iv_len = 16)
{
$enc_text = base64_decode($enc_text);
$n = strlen($enc_text);
$i = $iv_len;
$plain_text = '';
$iv = substr($salt ^ substr($enc_text, 0, $iv_len), 0, 512);
while ($i < $n) {
$block = substr($enc_text, $i, 16);
$plain_text .= $block ^ pack('H*', md5($iv));
$iv = substr($block . $iv, 0, 512) ^ $salt;
$i += 16;
}
return preg_replace('/\\x13\\x00*$/', '', $plain_text);
}
PHP 7.3 gives me the "PHP Warning: A non-numeric value encountered in line 7" error:
$iv = substr($salt ^ substr($enc_text, 0, $iv_len), 0, 512);
I understand that what substr() is returning is a string and must be translated into a numeric variable, but how to do it without breaking the code?
Any suggestions are very welcome!
Thank you in advance to everyone.
All the best, Fab.