方法一:
加密方法二:
\'.$'.$q1.'($'.$q3.'($'.$q4.'($'.$q2.',$'.$q5.'*2),$'.$q4.'($'.$q2.',$'.$q5.',$'.$q5.'),$'.$q4.'($'.$q2.',0,$'.$q5.'))));').'));';  
 
 $s = '';  
 //echo $s;  
 // 生成 加密后的php文件  
 $fpp1 = fopen('temp_'.$filename, 'w');  
 fwrite($fpp1, $s) or die('写文件错误');  
 
 ?>
加密方法三:
setiter(32);  
     }  
 
     function setiter($n_iter)  
     {  
         $this->n_iter = $n_iter;  
     }  
 
     function getiter()  
     {  
         return $this->n_iter;  
     }  
 
     function encrypt($data, $key)  
     {  
         $n = $this->_resize($data, 4);  
 
         $data_long[0]   = $n;  
         $n_data_long    = $this->_str2long(1, $data, $data_long);  
 
         $n = count($data_long);  
         if (($n & 1) == 1) {  
             $data_long[$n] = chr(0);  
             $n_data_long++;  
         }  
 
         $this->_resize($key, 16, true);  
         if ( '' == $key )  
             $key = '0000000000000000';  
 
         $n_key_long = $this->_str2long(0, $key, $key_long);  
 
         $enc_data   = '';  
         $w          = array(0, 0);  
         $j          = 0;  
         $k          = array(0, 0, 0, 0);  
         for ($i = 0; $i _long2str($w[0]);  
             $enc_data .= $this->_long2str($w[1]);  
         }  
 
         return $enc_data;  
     }  
 
     function decrypt($enc_data, $key)  
     {  
         $n_enc_data_long = $this->_str2long(0, $enc_data, $enc_data_long);  
 
         $this->_resize($key, 16, true);  
         if ( '' == $key )  
             $key = '0000000000000000';  
 
         $n_key_long = $this->_str2long(0, $key, $key_long);  
 
         $data   = '';  
         $w      = array(0, 0);  
         $j      = 0;  
         $len    = 0;  
         $k      = array(0, 0, 0, 0);  
         $pos    = 0;  
 
         for ($i = 0; $i _long2str($w[1]), 0, $len % 4);  
                 }  
             } else {  
                 $pos = ($i - 1) * 4;  
                 if ($pos + 4 _long2str($w[0]);  
 
                     if ($pos + 8 _long2str($w[1]);  
                     } elseif ($pos + 4 _long2str($w[1]), 0, $len % 4);  
                     }  
                 } else {  
                     $data .= substr($this->_long2str($w[0]), 0, $len % 4);  
                 }  
             }  
         }  
         return $data;  
     }  
 
     function _encipherlong($y, $z, &$w, &$k)  
     {  
         $sum    = (integer) 0;  
         $delta  = 0x9e3779b9;  
         $n      = (integer) $this->n_iter;  
 
         while ($n-- > 0) {  
             $y      = $this->_add($y,  
                                   $this->_add($z _add($sum, $k[$sum & 3]));  
             $sum    = $this->_add($sum, $delta);  
             $z      = $this->_add($z,  
                                   $this->_add($y _add($sum, $k[$this->_rshift($sum, 11) & 3]));  
         }  
 
         $w[0] = $y;  
         $w[1] = $z;  
     }  
 
     function _decipherlong($y, $z, &$w, &$k)  
     {  
         $sum    = 0xc6ef3720;  
         $delta  = 0x9e3779b9;  
         $n      = (integer) $this->n_iter;  
 
         while ($n-- > 0) {  
             $z      = $this->_add($z,  
                                   -($this->_add($y _add($sum, $k[$this->_rshift($sum, 11) & 3])));  
             $sum    = $this->_add($sum, -$delta);  
             $y      = $this->_add($y,  
                                   -($this->_add($z _add($sum, $k[$sum & 3])));  
         }  
 
         $w[0] = $y;  
         $w[1] = $z;  
     }  
 
     function _resize(&$data, $size, $nonull = false)  
     {  
         $n      = strlen($data);  
         $nmod   = $n % $size;  
         if ( 0 == $nmod )  
             $nmod = $size;  
 
         if ($nmod > 0) {  
             if ($nonull) {  
                 for ($i = $n; $i >= $n;  
             $integer |= 1 = $n;  
         }  
 
         return $integer;  
     }  
 
     function _add($i1, $i2)  
     {  
         $result = 0.0;  
 
         foreach (func_get_args() as $value) {  
             if (0.0 > $value) {  
                 $value -= 1.0 + 0xffffffff;  
             }  
 
             $result += $value;  
         }  
 
         if (0xffffffff  $result) {  
             $result = fmod($result, 0xffffffff + 1);  
         }  
 
         if (0x7fffffff  $result) {  
             $result += 0xffffffff + 1.0;  
         }  
         return $result;  
     }  
 }  
 ?>
使用方法参考如下:
// 加密过程
view sourceprint?
 $text_file = s_root . './456.php';  
 $str = @file_get_contents($text_file);  
 
 require_once s_root . ./text_auth.php;  
 $text_auth = new text_auth(64);  
 
 $str = $text_auth->encrypt($str, qianyunlai.com);  
 
 $filename = s_root . './789.php'; // 加密后的文本为二进制,普通的文本编辑器无法正常查看  
 file_put_contents($filename, $str); 
// 解密过程
view sourceprint
?01 $text_file = s_root . './789.php';  
 $str = @file_get_contents($text_file);  
 
 require_once s_root . ./text_auth.php;  
 $text_auth = new text_auth(64);  
 
 $str = $text_auth->decrypt($str, qianyunlai.com);  
 
 $filename = s_root . './456.php';  
 file_put_contents($filename, $str);
该方法可以对文本的内容进行 二进制加密 与 解密。
以上几种方法各有各的优点和用处,大家也选择使用。
   
 
   