CodeIgniter Forums
How to set encryption key in config - 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: How to set encryption key in config (/showthread.php?tid=75922)



How to set encryption key in config - beng - 03-29-2020

After reading the "Encryption Service" docs I cannot see a way to set the key as required e.g. using hex2bin();

In CI3 the config was just a variable in php file so I simply used:

PHP Code:
$key hex2bin('[32 bytes string]'

However you can't do this in the .env file or in the Encryption config file as you cant set the "public $key = '';" property to the result of a function.

Surely this defeats the object of having $key in the config?

I would like to set the key once, application wide so am I missing something here?

Many thanks,
Ben


RE: How to set encryption key in config - beng - 04-17-2020

Am I missing something here? anybody help?