Welcome Guest, Not a member yet? Register   Sign In
Decrypting: authentication error when using the encryption library
#1
Smile 

Hello friends,

I am currently trying to use the encryption library on Codeigniter 4 (I am not using it for passwords Smile  ). 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
Reply


Messages In This Thread
Decrypting: authentication error when using the encryption library - by ebuoe - 08-10-2020, 02:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB