Hey
I found this script somewhere while looking to find out how to encrypt page file names and it comes with the following information:
Here's the encryption script. You can run it on its own to play with it (it's got its own form for input and stuff), or you can copy the encrypt()/decrypt() functions and put them in the game or your own script. Read the big huge comment block at the top of the script for info about how it works.
Also... keep in mind that I wrote this about two and a half years ago, not too awful long after I learned PHP. I'm sure it could probably be improved, but, you know... please overlook any glaring errors and stuff. I was still learning at the time.
In the actual file instructions, it says this:
This is my crappy little attempt at basic encryption.
The basic reason behind my creating this is to send query strings as encrypted values rather than plain text.
Example: "www.site.com/me.php?x=23152754721726727029" rather than "www.site.com/me.php?page=1;var=asdf;value=pants".
This will (in theory) make it harder to hijack the script with a faked url.
The encryption basically takes a string, does a bunch of math on the ascii values of each character, and outputs
another string of what appears to be completely random numbers. It's not very secure, and characters with high
ascii values (such as "?quot will break it. But for simple encryption on a plain text message, it's quite adequate.
Theoretically the length of the string you can pass it is "unlimited", however, longer strings take longer to cypher.
I have chosen 20 as the standard length for a string, since I can't imagine any of the uses I have for it will
require anything longer than that - and so that all output contains the same number of characters, which makes it
slightly less obvious that the size of the output is directly related to the size of the input.
As far as efficiency goes, it takes approximately 1.25 seconds to encrypt and decrypt a thousand 20-char
string on my test computer (0.75 seconds on my live website). I have no basis for comparison to other
methods of encryption, so I have no idea whether that's good or bad. But the timer is in there, so you can
verify these results for yourself on whatever server you wish.
*/
Ive attached the file so you can all see. All i wana know is, how do i use it? I really dont know much php, but im sure its not that complicated...
Thanks if anyone can helplike he said:
you can copy the encrypt()/decrypt() functions and put them in the game or your own script.
all you need to do then is to use encrypt for you query string before you add it in the "href", and decrypt it in the next page to be able to extract the information.This is all good in theory but i dont have the slightest idea what your on about.
sorry.copy those functions into your script somewhere..
on your index page:
$url_para1 = "this_one";
$url_para2 = "the_second_one";
$url_para_encrypted = encrypt($url_para1 .";". $url_para2);
echo "<a href='http://www.someplace.com/index.php?var=". $url_para_encrypted ."'>click me</a>";
that'll do your link.
then in index.php, you handle it with:
if (isset($_GET['var']))
{
$url_para_unencrypt = decrypt($_GET['var']);
$url_paras = explode(";", $url_para_unencrypt);
}
now you have an array of parameters:
$url_paras[0] -> "this_one";
$url_paras[1] -> "the_second_one";It didnt work so i probably did something wrong..
nevermind..
I found this script somewhere while looking to find out how to encrypt page file names and it comes with the following information:
Here's the encryption script. You can run it on its own to play with it (it's got its own form for input and stuff), or you can copy the encrypt()/decrypt() functions and put them in the game or your own script. Read the big huge comment block at the top of the script for info about how it works.
Also... keep in mind that I wrote this about two and a half years ago, not too awful long after I learned PHP. I'm sure it could probably be improved, but, you know... please overlook any glaring errors and stuff. I was still learning at the time.
In the actual file instructions, it says this:
This is my crappy little attempt at basic encryption.
The basic reason behind my creating this is to send query strings as encrypted values rather than plain text.
Example: "www.site.com/me.php?x=23152754721726727029" rather than "www.site.com/me.php?page=1;var=asdf;value=pants".
This will (in theory) make it harder to hijack the script with a faked url.
The encryption basically takes a string, does a bunch of math on the ascii values of each character, and outputs
another string of what appears to be completely random numbers. It's not very secure, and characters with high
ascii values (such as "?quot will break it. But for simple encryption on a plain text message, it's quite adequate.
Theoretically the length of the string you can pass it is "unlimited", however, longer strings take longer to cypher.
I have chosen 20 as the standard length for a string, since I can't imagine any of the uses I have for it will
require anything longer than that - and so that all output contains the same number of characters, which makes it
slightly less obvious that the size of the output is directly related to the size of the input.
As far as efficiency goes, it takes approximately 1.25 seconds to encrypt and decrypt a thousand 20-char
string on my test computer (0.75 seconds on my live website). I have no basis for comparison to other
methods of encryption, so I have no idea whether that's good or bad. But the timer is in there, so you can
verify these results for yourself on whatever server you wish.
*/
Ive attached the file so you can all see. All i wana know is, how do i use it? I really dont know much php, but im sure its not that complicated...
Thanks if anyone can helplike he said:
you can copy the encrypt()/decrypt() functions and put them in the game or your own script.
all you need to do then is to use encrypt for you query string before you add it in the "href", and decrypt it in the next page to be able to extract the information.This is all good in theory but i dont have the slightest idea what your on about.
sorry.copy those functions into your script somewhere..
on your index page:
$url_para1 = "this_one";
$url_para2 = "the_second_one";
$url_para_encrypted = encrypt($url_para1 .";". $url_para2);
echo "<a href='http://www.someplace.com/index.php?var=". $url_para_encrypted ."'>click me</a>";
that'll do your link.
then in index.php, you handle it with:
if (isset($_GET['var']))
{
$url_para_unencrypt = decrypt($_GET['var']);
$url_paras = explode(";", $url_para_unencrypt);
}
now you have an array of parameters:
$url_paras[0] -> "this_one";
$url_paras[1] -> "the_second_one";It didnt work so i probably did something wrong..
nevermind..