MividDesigns
02-25-2004, 03:15 PM
I'm looking for a simple encryption/decryption function that will encrypt text into text that can be passed via querystring.
I have found some, but they encrypt the text to something like *&^)(*$#)(*$&%, but obviously that cannot be passed through a querystring.
This doesn't have to be super encrypted, i just dont want it to be a "readable" format.
Thanks in advanced!
rpepka
02-25-2004, 03:23 PM
how "encrypted" does it have to be? If it's not a extreme security issue, you can always use just a standard ROT13 function, or any rotation number that you want.
MividDesigns
02-25-2004, 03:28 PM
it is NOT an extreme security issue, but i dont want it to be able to be looked at and read.
I also should mention, I am wanting to do this with PHP.
I will look into ROT13. Thanks.
MividDesigns
02-25-2004, 03:30 PM
I think this might work:
<?
//******************************************
//
// Name: rot13
// Description:Rot13ify's any string.
// See also http://nehwon.xtn.net/rot13/
// by Christopher Heschong
// By: PHP Code Exchange
//******************************************
Function rot13($string) {
for($i=0;$i<strlen($string);$i++) {
$j=ord($string[$i]);
if ((($j>=ord("n")) & ($j<=ord("z"))) | ($j>=ord("N")) & ($j<=ord("Z"))) {
$j=$j-13;
}
elseif ((($j>=ord("a")) & ($j<=ord("m"))) | ($j>=ord("A")) & ($j<=ord("M"))) {
$j=$j+13;
}
$new.=chr($j);
}
return($new);
}
?>
rpepka
02-25-2004, 03:33 PM
That's exactly it. Hope that helps!
TDMWeb
02-25-2004, 06:55 PM
You need to encode the output from the encryption. See this for ideas:
http://www.phpbuilder.com/manual/function.urlencode.php
If you're going to use a rotation cypher then you may as well not bother.
MividDesigns
02-26-2004, 03:13 PM
Originally posted by TDMWeb
You need to encode the output from the encryption. See this for ideas:
http://www.phpbuilder.com/manual/function.urlencode.php
If you're going to use a rotation cypher then you may as well not bother.
Thanks alot! That takes care of my orig problem. No need to search for a new encryption function!
datacracker
02-26-2004, 05:03 PM
Php has a very well developed interface to the mcrypt library which will allow two way encryption using many different ciphers.
First make sure your php has been compiled with mcrypt support by checking the output of phpsysinfo()
mcrypt supports wide variety of block algorithms such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and a few others.
For more information on implementing mcrypt, checkout the mcrypt reference material at php's site (just search for mcrypt)
Slidey
02-27-2004, 05:43 AM
just so you know, rot13 will *not* give you any form of security past a cursorary glance.
MividDesigns
02-27-2004, 11:50 AM
Originally posted by Slidey
just so you know, rot13 will *not* give you any form of security past a cursorary glance.
that's all i'm really looking for :)
eegee
02-27-2004, 07:07 PM
hmm, md5() is good but its only one way
loopforever
02-27-2004, 07:23 PM
If PHP is compiled with mcrypt, that's the best way to go. As datacracker already said, there's lots of algorithms available and it's easy to implement. This is the best 2-way encryption method available for scripting in PHP.