I have 1 app for SSO, use CI 3. Now i am creating new app with CI 4. code in CI 3 for encryption :
$otp = 123;
$this->encryption->initialize(array(
'cipher' => 'aes-256',
'mode' => 'ctr',
'key' => '12345678901234567890123456789012'
));
echo $this->encryption->encrypt($otp);
//result 54322c75199be967a78c4d65906dd1d6a41c54027ddb2ff1a295c5646728f435cf4c3b5e793b57b6a6ecef34de7b7c1ed809632adeb02c5fabdf5f76befe4440PFRX6XAktE/jZXJKjL8fhCcqQw==
code in CI 4 for decryption :
$otp = '54322c75199be967a78c4d65906dd1d6a41c54027ddb2ff1a295c5646728f435cf4c3b5e793b57b6a6ecef34de7b7c1ed809632adeb02c5fabdf5f76befe4440PFRX6XAktE/jZXJKjL8fhCcqQw==';
$config = new \Config\Encryption();
$config->key = '12345678901234567890123456789012';
$config->driver = 'OpenSSL';
$encrypter = \Config\Services::encrypter($config);
echo $encrypter->decrypt($otp);
//result CodeIgniter\Encryption\Exceptions\EncryptionException Decrypting: authentication failed.
i have try with different option :
$config = new \Config\Encryption();
$config->key = '12345678901234567890123456789012';
$config->driver = 'OpenSSL';
$config->digest = 'sha256' or 'sha512';
Still getting message authentication failed. but in this documentation states that my CI 3 configuration it same with CI 4 even with default.