Столкнулся с тойже проблемой: на PHP 7.2 не поддерживается mCrypt, его нужно менять на OpenSSL. Нашел на английском форуме пример:
https://stackoverflow.com/questions/51160189/replace-mcrypt-encription-with-openssl-encription-for-opencart-cms
===
I'm currently changing over to 7.2 and are using the replacement below. I will remove the fallback to mcrypt later, it's just useful to be able to switch PHP versions. Also not you need to make sure you host has the sodium extension. It should be included as default in PHP 7.2, but some hosts are still not including it.There are other examples on the forums that use openssl. A search should find them.
Code: Select all
<?php
final class Encryption {
private $key;
public function __construct($key) {
$this->key = $key;
}
public function encrypt($value) {
if (function_exists('sodium_crypto_secretbox')) {
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
return strtr(base64_encode($nonce . sodium_crypto_secretbox($value, $nonce, hash('sha256', $this->key, true))), '+/=', '-_,');
} else {
return strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, hash('sha256', $this->key, true), $value, MCRYPT_MODE_ECB)), '+/=', '-_,');
}
}
public function decrypt($value) {
if (function_exists('sodium_crypto_secretbox')) {
$raw_value = base64_decode(strtr($value, '-_,', '+/='));
$nonce = substr($raw_value, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
return trim(sodium_crypto_secretbox_open(substr($raw_value, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES), $nonce, hash('sha256', $this->key, true)));
} else {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, hash('sha256', $this->key, true), base64_decode(strtr($value, '-_,', '+/=')), MCRYPT_MODE_ECB));
}
}
}
?>