CodeIgniter Forums
Use encrypt helper,how to - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Use encrypt helper,how to (/showthread.php?tid=9225)



Use encrypt helper,how to - El Forum - 06-17-2008

[eluser]chmod[/eluser]
I use CI's encrypt helper.

Code:
$datetime = date('Y-m-d H:i:s',time());
$keycode = $game_id.'|'.$area_id.'|'.$datetime;
$sid = $this->encrypt->encode($keycode);         $this->session->set_userdata('sid',$sid);


and the result of $sid maybe include following character :
space
+
=

when I use get pass $sid,the space character will be translate:
hexadecimal ,so the encrypt result will not equal.

If i want use enctypt helper ,but wipe out the space or + or =,how can I do?


Use encrypt helper,how to - El Forum - 06-17-2008

[eluser]Pascal Kriete[/eluser]
base64 encode the result, or if it's not critical data just base64 encode it from the start.


Use encrypt helper,how to - El Forum - 06-17-2008

[eluser]chmod[/eluser]
thanks,inparo

do you mean:
i use base64_encode($sid), and pass it to url,isn't it?


Use encrypt helper,how to - El Forum - 06-17-2008

[eluser]Pascal Kriete[/eluser]
Yes. However, if it's sensitive data you might have to do both. If you're storing it in the session anyways you could probably find a post free workaround as well.


Use encrypt helper,how to - El Forum - 06-17-2008

[eluser]chmod[/eluser]
[quote author="inparo" date="1213741699"]Yes. However, if it's sensitive data you might have to do both. If you're storing it in the session anyways you could probably find a post free workaround as well.[/quote]

I always use encrypt helper pass vars between pages by post,and the date is sensitive .