我正在尝试遵循关于加密的CI 3文档的说明https://codeigniter.com/userguide3/libraries/encryption.html#setting-your-encryption-key我应用了该指令,但它不能像我想的那样做出漂亮的输出,这里是标准代码
$this->load->library('encryption');
$key = $this->encryption->create_key(16);
// Get a hex-encoded representation of the key:
$key = bin2hex($this->encryption->create_key(16));
// Put the same value in your config with hex2bin(),
// so that it is still passed as binary to the library:
$config['encryption_key'] = hex2bin(<your hex-encoded key>);
但是我收到了这个错误
如何解决此错误?或者我写了一些错误的代码?
答案 0 :(得分:0)
如果使用加密类,则必须设置加密密钥。必须在不可分割的控制器上设置动态加密密钥。在config.php文件中设置加密密钥
//单个加密密钥
$ config [&#39; encryption_key&#39;] =&#39;&#39;;
//动态加密密钥 $这 - &GT;负载&GT;库(&#39;加密&#39); //在控制器中加载加密库
$ key = bin2hex($ this-&gt; encryption-&gt; create_key(16));
$ config [&#39; encryption_key&#39;] = hex2bin();