I have the following function that is written in php
function encrypt($string) {
//Key
$key = "key";
//Encryption
$cipher_alg = MCRYPT_TRIPLEDES;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg,MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt($cipher_alg, $key, $string, MCRYPT_MODE_ECB, $iv);
return base64_encode($encrypted_string);
return $encrypted_string;
}
A desktop application uses the same scheme to decrypt the generated string.Newer versions of PHP does not support mcrypt.How can i replace this code to achieve the same result?
Based on this site mcrypt has been removed from PHP 7.2 (which I assume you're using) and instead added to PECL. Assuming you're on Ubuntu or similar the process to install it now is to install the following dependencies:
Then install mcrypt via PECL:
The video on that first link from TechRepublic has more information as well.