Hello friends,
I am currently trying to use the encryption library on Codeigniter 4 (I am not using it for passwords
). When i use the $this->encrypter->encrypt($var) , it seems to work, cus I don't get any errors and I get what seems like gibberish in my database as I would want to.
However , when I fetch the encrypted data and try to decrypt I get this error : "Decrypting: authentication error" . Below are my codes.
Encryption config file
Code:
public $key = 'secret key';
Constructor to initialize service
Code:
public function __construct()
{
$this->encrypter = \Config\Services::encrypter();
}
Decrypting: authentication failedDecrypting: authentication failed
Encrypting data
Code:
$this->encrypter->encrypt($var)
Decrypting: authentication failed
Decrypt data
I tried both
Code:
<?=$encrypter->decrypt($var);?>
and
Code:
<?=$encrypter($var,$key);?>
Yet I was still getting errors, Any help is appreciated.
Regards.
Decrypting: authentication failedDecrypting: authentication failed