|
Posted by Daedalus.OS on 06/06/05 14:22
I don't see what you mean by " but I cannot encrypt the whole
string...unless i replaced the & with another character" ? I tested your
code by calling this:
$enc =
encrypt("PassedUserName='Hester'&PassedUserOccupation='Tester'","volatile");
$dec = decrypt($enc,"volatile");
echo "$enc<br>$dec";
Here is the output:
icbQ39TZzcHY2+G6wuHOqYy+1N/V2duTi5q/zdTnztC66dTesNfM4dXX49XQ4qaTudvi4MbmkA==PassedUserName='Hester'&PassedUserOccupation='Tester'On some other page I would then get the result (after decrypting$_GET['PassedData']) with a simple $result = split('&', $dec)... urlencodeand urldecode may also be useful if you want to include & into someparameter.Dae<plittle1970@hotmail.com> wrote in messagenews:1118052949.490444.204450@g47g2000cwa.googlegroups.com...> Hi there. My website passes information from one page to another via> the URL. it DOESN'T use forms or post/get but rather I build up the url> in page A as a string and use it to link to page B.>> My url looks (something)like this>http://www.mysite.com/pageb.php?PassedUserName='Hester'&PassedUserOccupation='Tester'>> I don't want users to be able to type in what ever entries they like,> but also I would like to hide the entire list of variables so that it> appears something like>> http://www.mysite.com/pageb.php?PassedData=<random looking data here>>> Now, I found these functions>> function encrypt($string, $key) {> $result = '';> for($i=0; $i<strlen($string); $i++) {> $char = substr($string, $i, 1);> $keychar = substr($key, ($i % strlen($key))-1, 1);> $char = chr(ord($char)+ord($keychar));> $result.=$char;> }> return base64_encode($result);> }>> function decrypt($string, $key) {> $result = '';> $string = base64_decode($string);>> for($i=0; $i<strlen($string); $i++) {> $char = substr($string, $i, 1);> $keychar = substr($key, ($i % strlen($key))-1, 1);> $char = chr(ord($char)-ord($keychar));> $result.=$char;> }> return $result;> }>> which work nicely on parts of the url giving me> PassedUserName='Hester'> xLTf1NfYvtXG5MLHztixerTG5ejO1Ig=>> PassedUserOccupation='Tester'> xLTf1NfYvtXG5MPJxOjktODK4eKmibXX59rG5Zs=>> but I cannot encrypt the whole string> PassedUserName='Hester'&PassedUserOccupation='Tester' unless i replaced> the & with another character for example but then I would have to> somehow split the string into the two variables, and be able to use> these values in my code.>> I guess appending a $ to the start of the decoded string isn't going to> work? (I doubt my problem would be that easily solved!)>> Sorry, I'm a bit green when it comes to Php programming and I've looked> through the PHP manual and tried many different ways of doing this> before I had to ask.>> Thanks in advance for any/all assistance>
[Back to original message]
|