I have OpenCart 1.5.6.4
with encryption.php
file in system library folder
.
The codes in encryption.php
are :
<?php
final class Encryption {
private $key;
private $iv;
public function __construct($key) {
$this->key = hash('sha256', $key, true);
$this->iv = mcrypt_create_iv(32, MCRYPT_RAND);
}
public function encrypt($value) {
return strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->key, $value, MCRYPT_MODE_ECB, $this->iv)), '+/=', '-_,');
}
public function decrypt($value) {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->key, base64_decode(strtr($value, '-_,', '+/=')), MCRYPT_MODE_ECB, $this->iv));
}
}
?>
For migration from php 5.6
to php 7.2
, I need to replace Mcrypt Encription
with OpenSSL Encription
.
I have replaced mcrypt_create_iv(32, MCRYPT_RAND)
with openssl_random_pseudo_bytes(32, true)
, but for encrypt function
and decrypt function
, I do not know what parameters
to use for these functions.
What changes needed in encription.php
codes?