Using base64 encoded string URL
base64, php, url, zend-framework
Solution
I strongly recommend Joe Riggs' Create URL Safe Encrypted String.
The supplied code is in procedural, but is extremely simple to convert to OO. I have used it to do what you are doing in which some information (usually a hash of the user's email and id) is encoded/encrypted for the user to click on to activate their account.
The functions you want to look at are `url_base64_decode` and `url_base64_encode`, in which certain characters are rewritten to be url safe (for example, removing `/` and replacing it with `~`).
[edit]
Here is a codepad of my class based on the above code: http://codepad.org/lzevA4k1
Usage:
$cryptUtil = new RPK_Crypt();
$string = 'Unencrypted string';
$eString = $cryptUtil->encrypt($string);
$dString = $cryptUtil->decrypt($eString);
var_dump($dString == $string); //true
Problem
Possible Duplicate: Passing base64 encoded strings in URL I am working on creating a url that will be sent to user. User then clicks the url and this URL tells me who the user is. So all the data I have added to this link using base64 encode. However when user clicks the link he gets redirected to 404 page since encoded url has '/' in it and zend framework router does not find any routes for it. Any way I can suppress the '/'? I tried `htmlentities` but it did not work.