Decrypting parameters Codeigniter

怎甘沉沦 提交于 2020-01-07 04:27:07

问题


I have a small problem. I am sending a mail when an item needs attention. I am getting the encrypted string, but when I decrypt it I get nothing .. Anything wrong in my code? Thanks in advance

Encrypting parameter (ID):

$this->load->library('encrypt');
$yes = site_url('job/itemFree/?id='.$this->encrypt->encode($itemid));
$no = site_url('job/itemExtend/?id='.$this->encrypt->encode($itemid));

Decrypting :

$this->load->library('encrypt');
$id = $_GET['id'];
$id = $this->encrypt->decode($id);
echo $id;

回答1:


try this

$this->load->library('encrypt');
$yes = site_url('job/itemFree/?id='.urlencode($this->encrypt->encode($itemid)));
$no = site_url('job/itemFree/?id='.urlencode($this->encrypt->encode($itemid)));



回答2:


instead of passing parameter in id using get you can do it like this

$this->load->library('encrypt');
$yes    =   site_url('job/itemFree/'.$this->encrypt->encode($itemid));
$no     =   site_url('job/itemExtend/'.$this->encrypt->encode($itemid));

Now to get it you need to do.

$this->load->library('encrypt');
$id         =   $this->uri->segment(3);
$decoded_id =   $this->encrypt->decode($id);
echo $decoded_id;   


来源:https://stackoverflow.com/questions/20395160/decrypting-parameters-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!