PHP代码点火器加密不会返回任何内容

时间:2012-11-10 21:45:31

标签: php codeigniter url encryption decode

当我加载我的控制器时,我有这个:

$this->load->library('encrypt');

$get = null;
parse_str($_SERVER['QUERY_STRING'],$get);
$email = $this->encrypt->decode($get["acc"]); // e.g.  www.lol.com/?acc=troll

我的控制器就像这样调用:

$this->load->library('encrypt');
$this->load->helper("url");
$user = $this->input->post('email', true);

$encrypted_string = $this->encrypt->encode($user);
redirect('account/viewaccount?acc='.$encrypted_string);

网址如下:

http://localhost/CodeIgniter/index.php/account/viewaccount?acc=+fgSAs6X7ysW6XDjFVw//9RGVbY751zZv1LQ44yYBjhVuzI1BC1t9BbZCIUdX5lpYA==

但问题是,当我编码我得到一个值,但后来,当我解码这个巨大的值(我可以通过测试得到这个值完美无瑕)它没有返回任何东西,只是NULL。

为什么会这样?

谢谢

3 个答案:

答案 0 :(得分:3)

加密的输出不是URL安全的。替换这个:

redirect('account/viewaccount?acc='.$encrypted_string);

使用

redirect('account/viewaccount?acc='.urlencode($encrypted_string));

然后urldecode()在另一端。

答案 1 :(得分:0)

尝试加密字符串并解密它。 错误可能不是解密或加密

答案 2 :(得分:0)

编码表单不是网址安全,请尝试使用其他编码技术或urlencode encode的输出。