What has been changed
The support for
MCrypthas been dropped, as that has been deprecated as of PHP 7.2.
Within your configs the
$config['encryption_key'] = 'abc123';moved from application/config/config.php to
public $key = 'abc123';in app/Config/Encryption.php.
If you need to decrypt data encrypted with CI3’s Encryption, configure settings to maintain compatibility. See Configuration to Maintain Compatibility with CI3.
Wherever you have used the encryption library you have to replace
$encrypter = service('encrypter');and change the methods for encryption and decrypting like in the following code example.
CodeIgniter Version 3.x
<?php $this->load->library('encryption'); $plain_text = 'This is a plain-text message!'; $ciphertext = $this->encryption->encrypt($plain_text); // Outputs: This is a plain-text message! echo $this->encryption->decrypt($ciphertext);
CodeIgniter Version 4.x
<?php $encrypter = service('encrypter'); $plainText = 'This is a plain-text message!'; $ciphertext = $encrypter->encrypt($plainText); // Outputs: This is a plain-text message! echo $encrypter->decrypt($ciphertext);