CodeIgniter Forums
How to pass encrypt GET variable - 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: How to pass encrypt GET variable (/showthread.php?tid=12380)



How to pass encrypt GET variable - El Forum - 10-16-2008

[eluser]lamperz[/eluser]
Hi, guys
I'm development some kind of register confirm.

URL likes
http://www.example.com/apply/confirm/A2AAb1+0W1Vbw
was sended to user by email.

character likes A2AAb1+0W1Vbw was username encrypted by CI's encrypt library.

But I got "/" or "+" in ciphertext occasionally, AND those
characters is illegal in URL.

Any idea?
I'll waitting online


How to pass encrypt GET variable - El Forum - 10-16-2008

[eluser]lamperz[/eluser]
I found ~ _ - was in $config['permitted_uri_chars']
and illegal characters is + = /
so we can str_replace + = / with ~ _ -


How to pass encrypt GET variable - El Forum - 10-16-2008

[eluser]sobencha[/eluser]
Couldn't you just use the PHP urlencode() function? If you used this when creating the email containing the URL, it should escape any of the characters causing you problems. Then just use the urldecode() function when you process and unencrypt the string.


How to pass encrypt GET variable - El Forum - 10-16-2008

[eluser]lamperz[/eluser]
urlencode will bring in % which is also illegal charactor in CI config


How to pass encrypt GET variable - El Forum - 10-17-2008

[eluser]oll[/eluser]
You should use sthing like :

$key=md5(uniqid($username));
and send :
http://mysite/controller/model/$key as url

You don't have to use the encrypt helper (at least not in the goal of being able to decrypt the key for knowing the user).
Just create a waitforconfirm table with at least 2 fields : a username field and a "password" field.


You will know your user using a query that looks like : "select * from waitforconfirm where password=$key"

This link might help :
http://www.phpeasystep.com/workshopview.php?id=24


How to pass encrypt GET variable - El Forum - 10-17-2008

[eluser]Derek Allard[/eluser]
What about
Code:
$this->load->helper('string');
$random_passkey = random_string('alnum', 13);