Page 1 of 1
Key for base64_encode()
Posted: Sat Jun 05, 2004 1:42 pm
by anjanesh
Hello
For every encryption algo there is a key. So when we do $str=base64_encode ("test"); what is the key and if the key is stored in $str then does that mean php codes it using only one key ? Is it not popssible to choose the key ourselves ?
Thanks
Posted: Sat Jun 05, 2004 1:53 pm
by feyd
base64_encode() isn't really an encryption per se.. it's entirely open.. binary data is converted into 2^6 (64) chunks.. the key is already known to the algorithm as it's always the same (a-z,A-Z,0-9,a few symbols) which comes to 64 characters which have a distinct representation when indexed as an array..
Posted: Sat Jun 05, 2004 1:59 pm
by feyd
here's a way (untested) to find the array
Code: Select all
$str = "";
for($x = 0; $x < 64; $x++) $str .= chr($x);
echo base64_encode($str);
Posted: Sat Jun 05, 2004 2:23 pm
by anjanesh
In that case what do I have to do to send encrypted data ? I am sending them as a paramter in the url. libmcrypt ? I am not getting that to work in the local system. I think the conf has to do with it.
Posted: Sat Jun 05, 2004 2:52 pm
by launchcode
There's no real secure way to send data via the query string - it depends how sensitive you need this data to be. You could store it in a temp. SQL table (or session) and then just pass the ID across, so the receiving script can then extract this data again - or if all you want to do is a little mangling of the data so it isn't obvious what it says, then you could encode it a few different ways using some of the functions built into PHP.
Posted: Sat Jun 05, 2004 9:42 pm
by anjanesh
How about using the libmcrypt functions ? I could not test it at home because for some reason the mcrypt() is not working. Probably conf prob. So I am asking here.
Posted: Sat Jun 05, 2004 9:54 pm
by launchcode
mcrypt with a secret key would work fine, if you really need to do it that way.