Reputation: 1292
when i load my controller i have this:
$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
And my controller is called like this:
$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);
The url looks like this:
http://localhost/CodeIgniter/index.php/account/viewaccount?acc=+fgSAs6X7ysW6XDjFVw//9RGVbY751zZv1LQ44yYBjhVuzI1BC1t9BbZCIUdX5lpYA==
But the problem is, when i encode i get a value, but then later on, when i decode this huge value (I can receive this value flawless, by testing) it returns nothing, just NULL.
Why is this happening?
Thank You
Upvotes: 1
Views: 1312
Reputation: 4819
The output of the encryption is not URL safe. Replace this:
redirect('account/viewaccount?acc='.$encrypted_string);
With
redirect('account/viewaccount?acc='.urlencode($encrypted_string));
And then urldecode()
it on the other end.
Upvotes: 3
Reputation: 1221
Encoded form is not url safe, try using some other encoding technique or urlencode
the output of encode
.
Upvotes: 0
Reputation: 124
try encrypting a string and decrypt it. the error may not be the decryption or encryption
Upvotes: 0