The function below correctly decrypt the data in php5
function decrypt_mcrypt($key, $str) {
$str = base64_decode($str);
$iv = substr($str, 0, 16);
$str = substr($str, 16);
return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_CFB, $iv);
}
I tried to use openssl instead of mcrypt (in php7), but got garbage on the output.
function decrypt_openssl($key, $str) {
$str = base64_decode($str);
$iv = substr($str, 0, 16);
$str = substr($str, 16);
return openssl_decrypt($str, 'AES-256-CFB', $key, OPENSSL_RAW_DATA, $iv);
}
What could be the problem?