Decrypting parameters Codeigniter

2019-08-28 20:49发布

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;

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-28 21:25

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)));
查看更多
戒情不戒烟
3楼-- · 2019-08-28 21:33

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;   
查看更多
登录 后发表回答