quick question.

have someone a better solution for link encryption?

here is mine

-------

<?
        // func_cryption_old.inc.php

        function fnCrypt($string){
                settype($string, "string");

                $string = trim($string);

                if(!$string){
                        return false;
                }

                return fnCryptV1($string);
        }

        function fnDeCrypt($string){
                settype($string, "string");

                $string = trim($string);

                switch(substr($string,strlen($string)-1,1)){
                        case "1";

                                $string = 
fnDeCryptV1(substr($string,0,strlen($string)-2));
                                break;
                }

                return $string;
        }

        function fnCryptV1($string){
                srand((double)microtime()*3199248);

                $rand = rand(1,128);

                $max = bcsub(255,$rand,0);

                $text_plain = trim($string);

                $num = strlen($text_plain);

                $text_inter = "";
                $text_hex   = "";
                $text_pack  = "";

                for($schleife=0; $schleife<$num; $schleife++){
                        $bit = ord(substr($text_plain,$schleife,1));

                        $bit_inter = trim(bcsub($max,$bit,0));
                        $bit_hex   = trim(dechex($bit_inter));

                        if(strlen($bit_hex) != 2){
                                $bit_hex = "0".$bit_hex;
                        }

                        $text_hex .= $bit_hex;
                }

                $rand_hex = dechex($rand);

                if(strlen($rand_hex) != 2){
                        $rand_hex = "0".$rand_hex;
                }

                $text_hex = $rand_hex.$text_hex;

                $text_pack = pack("H*",$text_hex);

                $text_base64 = base64_encode($text_pack)."v1";

                return $text_base64;
        }

        function fnDeCryptV1($string){
                settype($string, "string");

                $string = trim($string);

                $feedback = "";

                $text_base64 = base64_decode($string);

                $text_unpack = implode("",unpack("H*",$text_base64));

                $rang = hexdec(substr($text_unpack,0,2));
                $max  = bcsub(255,$rang,0);

                $text_unpack = substr($text_unpack,2);

                $num  = strlen($text_unpack);

                for($schleife=0; $schleife<$num; $schleife = bcadd($schleife,2,0)){
                        $hex = substr($text_unpack,$schleife,2);

                        $bit_dec   = trim(hexdec($hex));
                        $bit_uninter = trim(bcsub($max,$bit_dec,0));

                        $feedback .= chr($bit_uninter);

                }

                //echo "($feedback)";
                return $feedback;
        }

?>

----

but it suxx,... often the links are toooooooooo long....

have someone an better code +hoping+ or even an documention for self-coding?

greetz
CBQ

-- 
GMX ProMail (250 MB Mailbox, 50 FreeSMS, Virenschutz, 2,99 EUR/Monat...)
jetzt 3 Monate GRATIS + 3x DER SPIEGEL +++ http://www.gmx.net/derspiegel +++

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to