I just changed the php version I'm using in Xampp (to a lower version) and I'm having errors with the encryption functions. In other similar questions I saw that it was worth removing the; before extension=php_openssl.dll
in php.ini
(use windows), but it has not worked for me. I have tried to use the mcrypt_module_open()
function by uncommenting the lines extension=php_mcrypt.dll
and extension=php_mcrypt_filter.dll
, but I have the same problem. I have done this operation with all the .ini that I have found but nothing.
I've also seen answers where they say you have to modify the file phpForApache.ini
, but I do not have such a file.
My code, which worked with PHP 7, is as follows:
function encrypt_decrypt($string, $action, $encrypt_method, $key, $iv)
{
$resultado = false;
if( $action == 'e' )
{
$resultado = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
}
else if( $action == 'd' )
{
$resultado = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
}
return $resultado;
};