CodeIgniter Forums
Encrypter class error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Encrypter class error (/showthread.php?tid=77108)



Encrypter class error - zoom360 - 07-20-2020

I have used encrypter class:

Code:
$this->encrypter = \Config\Services::encrypter();

$abc = 'abc/def/ghi';
$encrypt = $this->encrypter->encrypt($abc);
$decrypt = $this->encrypter->decrypt($encrypt);
There is an error "authentication failed".


RE: Encrypter class error - InsiteFX - 07-20-2020

You should use base_64 encode and decode for that.

Other wise illegal characters can cause it to crash.


RE: Encrypter class error - ebuoe - 08-12-2020

(07-20-2020, 12:16 AM)zoom360 Wrote: I have used encrypter class:

Code:
$this->encrypter = \Config\Services::encrypter();

$abc = 'abc/def/ghi';
$encrypt = $this->encrypter->encrypt($abc);
$decrypt = $this->encrypter->decrypt($encrypt);
There is an error "authentication failed".


Hi , I had a similar problem , you have to load the default encryption configuration in the config folder this way:



PHP Code:
public function __construct(){

  $this->config    = new \Config\Encryption();      // load the configuration for the encryption service
  $this->encrypter = \Config\Services::encrypter($this->config); // start the encryption service



And then you can use $this->encrypter to encrcypt and decrypt, also ensure that OpenSSL is enabled in php.ini , I asked and found the solution to the same problem here


RE: Encrypter class error - zoom360 - 08-12-2020

(08-12-2020, 05:22 AM)ebuoe Wrote:
(07-20-2020, 12:16 AM)zoom360 Wrote: I have used encrypter class:

Code:
$this->encrypter = \Config\Services::encrypter();

$abc = 'abc/def/ghi';
$encrypt = $this->encrypter->encrypt($abc);
$decrypt = $this->encrypter->decrypt($encrypt);
There is an error "authentication failed".


Hi , I had a similar problem , you have to load the default encryption configuration in the config folder this way:



PHP Code:
public function __construct(){

  $this->config    = new \Config\Encryption();      // load the configuration for the encryption service
  $this->encrypter = \Config\Services::encrypter($this->config); // start the encryption service



And then you can use $this->encrypter to encrcypt and decrypt, also ensure that OpenSSL is enabled in php.ini , I asked and found the solution to the same problem here
Thanks !