GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   encrypting address bar string with php (https://gfy.com/showthread.php?t=92296)

magnatique 12-06-2002 12:44 PM

encrypting address bar string with php
 
I need to encrypt a string in the status bar so that I can pass

?string=798&Wwehkl3elkjdslade

instead of something like

?info1=true&info2=false&info3=true

NOW....

I need to know what encrypting language I need to use..

I was gonna use mcrypt... but it seems des and all the other encrypting things I used create some weird characters... I need to pass it through the browser address bar, so it needs to be numbers and letters...

can anyone guide me with this please?

extreme 12-06-2002 12:54 PM

for what purpose?

theharvman 12-06-2002 12:56 PM

.

modF 12-06-2002 12:57 PM

Will urlencode() work?

magnatique 12-06-2002 12:59 PM

I wanna build a page where I pass my page's options through the url.... BUT, I don't want to have the surfers able to modify the page by changing what's in the top

magnatique 12-06-2002 01:03 PM

I believe urlencode is only to change spaces with something else or something.....

Backov 12-06-2002 01:07 PM

urlencode the results the crypt returns.

Edit: On second thought, this is a really dumb suggestion. Don't bother with this at all - use sessions for this. It's a much better way of doing what you want.

Cheers,
Backov

magnatique 12-06-2002 01:09 PM

hey backov...

yeah, that's what I was thinking...

but it makes a huge freakin' url though LOL....

there's no encryption/decryption package that uses letters and numbers only?

magnatique 12-06-2002 01:14 PM

I'm a rookie at php my friend ;)

what do you mean with sessions..

you mean session_encode ?

foe 12-06-2002 01:15 PM

Use Sessions :thumbsup

CowboyAtHeart 12-06-2002 01:16 PM

Use a hash of the values combined with a secret key.

var1=foo&var2=bar&var3=baz&key=3837s7743

in the php, do something like.
generate key:
$key = crypt("var1=foo&bar2=bar&var3=baz" . $mysecretkey)

check:
if ($key == crypt("var1=$var1&var2=$var2&var3=$var3" . $mysecretkey)) { // good value }
else {
//bad value, someone chaned something
}

Unless they know your secret key, they can't
change the values, without screwing up the
key. (which is basically just a checksum
of the values they originally had)

Of course, sessions is probably a better solution.
And if you're sure the users support cookies,
they can be done through cookies alone,
not using the ugly urls.

foe 12-06-2002 01:18 PM

Quote:

Originally posted by magnatique
I'm a rookie at php my friend ;)

what do you mean with sessions..

you mean session_encode ?

found this randomly online

http://codewalkers.com/tutorials.php?show=32

read it

magnatique 12-06-2002 01:21 PM

yeah, the key thing is a solution :)

thanks for all the info guys... will find it out I guess ;)

xroach 12-06-2002 01:23 PM

Quote:

Originally posted by magnatique
I need to encrypt a string in the status bar so that I can pass

?string=798&Wwehkl3elkjdslade

instead of something like

?info1=true&info2=false&info3=true

NOW....

I need to know what encrypting language I need to use..

I was gonna use mcrypt... but it seems des and all the other encrypting things I used create some weird characters... I need to pass it through the browser address bar, so it needs to be numbers and letters...

can anyone guide me with this please?



encrypt it with mcrytp, the use bin2hex and pass the hex value .. then use hex2bin before you unencrypt it

here .. bin2hex is built in

function encrypt($key, $data)
{
$plain_text = trim($data);
$iv = substr(md5($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
$c_t = mcrypt_encrypt (MCRYPT_CAST_256, $key, $plain_text, "cfb", $iv);
return trim(chop(base64_encode($c_t)));
}


function decrypt($key, $c_t)
{
$c_t = trim(chop(base64_decode($c_t)));
$iv = substr(md5($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
$p_t = mcrypt_decrypt (MCRYPT_CAST_256, $key, $c_t, "cfb", $iv);
return trim(chop($p_t));
}

function hex2bin($data) {
$len = strlen($data);
for ($i=0;$i<$len;$i+=2) {
$newdata .= pack("C",hexdec(substr($data,$i,2)));
}
return $newdata;
}

magnatique 12-06-2002 02:21 PM

xroach, thanks a lot dude...

that made my day ;)

xroach 12-06-2002 02:28 PM

Quote:

Originally posted by magnatique
xroach, thanks a lot dude...

that made my day ;)



no worries :thumbsup


All times are GMT -7. The time now is 11:18 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123