codeigniter 加密密钥保存在外部文件中并在加密库中设置。

codeigniter encryption key to save in external file and set in encrypt library.

您好,我需要 codeigniter 加密库加密密钥来设置外部文件,因为出于安全考虑,我不想将其设置在 config.php 文件中。

 $config['encryption_key'] = 'my_key';

制作一个新的配置文件 application/config/config1.php.with

$config['encryption_key'] = 'my_key';

现在从 application/config/autoload.php 加载它,如下所示:

$autoload['config'] = array('config1');

您可以使用加载自定义配置文件:-

创建自定义配置文件后,我们需要加载它以获取它的项目。对于加载自定义配置,我们有两种方法。

  1. 手动加载:- 我们可以在 controller/model 中手动加载配置文件,例如

     $this->config->load('file_name'); //or use custom_config instead of file_name
    

其中“file_name”是不带 .php 扩展名的自定义配置文件名。

  1. 自动加载:- 对于自动加载配置文件,转到“application/config/autoload.php”并在 $autoload['config']

    中添加代码
    $autoload['config'] = array('config_custom'); //where config_custom is your file name.