方式一:
1<?php 2/** 3 * Created by PhpStorm. 4 * User: Yang 5 * Date: 2019/10/16 6 * Time: 10:25 7 */ 8 9 10class Encipher { 11 12 private $_sourceFile = ''; 13 private $_encodedFile = ''; 14 private $_comments = array( 15 'Author: Yang', 16 'Email: 1017836267@qq.com' 17 ); 18 19 public function __construct($sourceFile, $encodeFile, $comments = array()) 20 { 21 !empty($sourceFile) && $this->_sourceFile = $sourceFile; 22 !empty($encodeFile) && $this->_encodedFile = $encodeFile; 23 !empty($comments) && $this->comments = (array)$comments; 24 25 if (empty($this->_sourceFile) || !file_exists($this->_sourceFile)) { 26 exit("Source file does not exist."); 27 } 28 if (empty($this->_encodedFile) || !file_exists($this->_encodedFile)) { 29 //如果源文件不存在,则创建 30 fopen($this->_encodedFile, "w"); 31 } 32 } 33 34 /** 35 * 返回随机字符串 36 * @return string 37 */ 38 private function createRandKey() 39 { // 返回随机字符串 40 $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 41 return str_shuffle($str); 42 } 43 44 /** 45 * 加密函数 46 * @return bool 47 */ 48 public function encode() { 49 //随机密匙1 50 $k1 = $this->createRandKey(); 51 //随机密匙2 52 $k2 = $this->createRandKey(); 53 // 获取源文件内容 54 $sourceContent = file_get_contents($this->_sourceFile); 55 //base64加密 56 $base64 = base64_encode($sourceContent); 57 //根据密匙替换对应字符。 58 $c = strtr($base64, $k1, $k2); 59 $c = $k1 . $k2 . $c; 60 $q1 = "O00O0O"; 61 $q2 = "O0O000"; 62 $q3 = "O0OO00"; 63 $q4 = "OO0O00"; 64 $q5 = "OO0000"; 65 $q6 = "O00OO0"; 66 $encodeContent = '$' . $q6 . '=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$' . $q1 . '=$' . $q6 . '{3}.$' . $q6 . '{6}.$' . $q6 . '{33}.$' . $q6 . '{30};$' . $q3 . '=$' . $q6 . '{33}.$' . $q6 . '{10}.$' . $q6 . '{24}.$' . $q6 . '{10}.$' . $q6 . '{24};$' . $q4 . '=$' . $q3 . '{0}.$' . $q6 . '{18}.$' . $q6 . '{3}.$' . $q3 . '{0}.$' . $q3 . '{1}.$' . $q6 . '{24};$' . $q5 . '=$' . $q6 . '{7}.$' . $q6 . '{13};$' . $q1 . '.=$' . $q6 . '{22}.$' . $q6 . '{36}.$' . $q6 . '{29}.$' . $q6 . '{26}.$' . $q6 . '{30}.$' . $q6 . '{32}.$' . $q6 . '{35}.$' . $q6 . '{26}.$' . $q6 . '{30};eval($' . $q1 . '("' . base64_encode('$' . $q2 . '="' . $c . '";eval(\'?>\'.$' . $q1 . '($' . $q3 . '($' . $q4 . '($' . $q2 . ',$' . $q5 . '*2),$' . $q4 . '($' . $q2 . ',$' . $q5 . ',$' . $q5 . '),$' . $q4 . '($' . $q2 . ',0,$' . $q5 . '))));') . '"));'; 67 $headers = array_map('trim', array_merge(array('/*'), $this->_comments, array('*/'))); 68 $enCode = "<?php"."\r\n".implode("\r\n", $headers) . "\r\n".$encodeContent."\r\n"."?>"; 69 $file = fopen($this->_encodedFile, 'w'); 70 return fwrite($file, $enCode) or die('写文件错误'); 71 } 72} 73 74 75$e = new Encipher("index.php", "test_1.php"); 76$e ->encode(); 77echo "加密成功";

方式一改进版:
1<?php 2/** 3 * Created by PhpStorm. 4 * User: Yang 5 * Date: 2019/10/16 6 * Time: 10:25 7 */ 8 9 10class Encipher 11{ 12 13 private $c = ''; 14 private $_sourceFile = ''; 15 private $_targetFile = ''; 16 private $_writeContent = ''; 17 private $_comments = array( 18 'Author: Yang', 19 'Email: 1017836267@qq.com' 20 ); 21 22 public function __construct($sourceFile, $targetFile, $comments = array()) 23 { 24 !empty($sourceFile) && $this->_sourceFile = $sourceFile; 25 !empty($targetFile) && $this->_targetFile = $targetFile; 26 !empty($comments) && $this->comments = (array)$comments; 27 28 if (empty($this->_sourceFile) || !file_exists($this->_sourceFile)) { 29 exit("Source file does not exist."); 30 } 31 if (empty($this->_targetFile) || !file_exists($this->_targetFile)) { 32 //如果源文件不存在,则创建 33 fopen($this->_targetFile, "w"); 34 } 35 $this->init(); 36 } 37 38 private function init() 39 { 40 $this->q1 = "O00O0O";//base64_decode 41 $this->q2 = "O0O000";//$c(原文经过strtr置换后的密文,由 目标字符+替换字符+base64_encode(‘原文内容’)构成) 42 $this->q3 = "O0OO00";//strtr 43 $this->q4 = "OO0O00";//substr 44 $this->q5 = "OO0000";//52 45 $this->q6 = "O00OO0";//urldecode解析过的字符串(n1zb/ma5\vt0i28-pxuqy*6%6Crkdg9_ehcswo4+f37j) 46 } 47 48 /** 49 * 返回随机字符串 50 * @return string 51 */ 52 private function createRandKey() 53 { // 返回随机字符串 54 $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 55 return str_shuffle($str); 56 } 57 58 /** 59 * 写入文件 60 * @param $targetFile 写入文件的路径 61 * @return $this 62 */ 63 private function write($targetFile) 64 { 65 $file = fopen($targetFile, 'w'); 66 fwrite($file, $this->_writeContent) or die('写文件错误'); 67 fclose($file); 68 return $this; 69 } 70 71 /** 72 * 对明文内容进行加密处理 73 * @param $sourceFile 要加密的文件路径 74 * @return $this 75 */ 76 private function encodeText($sourceFile) 77 { 78 //随机密匙1 79 $k1 = $this->createRandKey(); 80 //随机密匙2 81 $k2 = $this->createRandKey(); 82 // 获取源文件内容 83 $sourceContent = file_get_contents($sourceFile); 84 //base64加密 85 $base64 = base64_encode($sourceContent); 86 //根据密匙替换对应字符。 87 $c = strtr($base64, $k1, $k2); 88 $this->c = $k1 . $k2 . $c; 89 return $this; 90 } 91 92 private function encodeTemplate() 93 { 94 $encodeContent = '$' . $this->q6 . '=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$' . $this->q1 . '=$' . $this->q6 . '{3}.$' . $this->q6 . '{6}.$' . $this->q6 . '{33}.$' . $this->q6 . '{30};$' . $this->q3 . '=$' . $this->q6 . '{33}.$' . $this->q6 . '{10}.$' . $this->q6 . '{24}.$' . $this->q6 . '{10}.$' . $this->q6 . '{24};$' . $this->q4 . '=$' . $this->q3 . '{0}.$' . $this->q6 . '{18}.$' . $this->q6 . '{3}.$' . $this->q3 . '{0}.$' . $this->q3 . '{1}.$' . $this->q6 . '{24};$' . $this->q5 . '=$' . $this->q6 . '{7}.$' . $this->q6 . '{13};$' . $this->q1 . '.=$' . $this->q6 . '{22}.$' . $this->q6 . '{36}.$' . $this->q6 . '{29}.$' . $this->q6 . '{26}.$' . $this->q6 . '{30}.$' . $this->q6 . '{32}.$' . $this->q6 . '{35}.$' . $this->q6 . '{26}.$' . $this->q6 . '{30};eval($' . $this->q1 . '("' . base64_encode('$' . $this->q2 . '="' . $this->c . '";eval(\'?>\'.$' . $this->q1 . '($' . $this->q3 . '($' . $this->q4 . '($' . $this->q2 . ',$' . $this->q5 . '*2),$' . $this->q4 . '($' . $this->q2 . ',$' . $this->q5 . ',$' . $this->q5 . '),$' . $this->q4 . '($' . $this->q2 . ',0,$' . $this->q5 . '))));') . '"));'; 95 $headers = array_map('trim', array_merge(array('/*'), $this->_comments, array('*/'))); 96 $this->_writeContent = "<?php" . "\r\n" . implode("\r\n", $headers) . "\r\n" . $encodeContent . "\r\n" . "?>"; 97 return $this; 98 } 99 100 /** 101 * 获取解密后内容 102 * @param $sourceFileContent 解密前内容 103 * @return $this 104 */ 105 private function decodeTemplate($sourceFileContent) 106 { 107 //以eval为标志 截取为数组,前半部分为密文中的替换掉的函数名,后半部分为密文 108 $m = explode('eval',$sourceFileContent); 109 //对系统函数的替换部分进行执行,得到系统变量 110 $varStr = substr($m[0],strpos($m[0],'$')); 111 //执行后,后续就可以使用替换后的系统函数名 112 eval($varStr); 113 //判断是否有密文 114 if(!isset($m[1])){ 115 return $this; 116 } 117 118 //对密文进行截取 {$this->q4} substr 119 $star = strripos($m[1],'('); 120 $end = strpos($m[1],')'); 121 $str = ${$this->q4}($m[1],$star,$end); 122 //对密文解密 {$this->q1} base64_decode 123 $str = ${$this->q1}($str); 124 //截取出解密后的 核心密文 125 $evallen = strpos($str,'eval'); 126 $str = substr($str,0,$evallen); 127 //执行核心密文 使系统变量被赋予值 $O0O000 128 eval($str); 129 $this->_writeContent = ${$this->q1}( 130 ${$this->q3}( 131 ${$this->q4}( 132 ${$this->q2},${$this->q5}*2 133 ), 134 ${$this->q4}( 135 ${$this->q2},${$this->q5},${$this->q5} 136 ), 137 ${$this->q4}( 138 ${$this->q2},0,${$this->q5} 139 ) 140 ) 141 ); 142 return $this; 143 } 144 145 /** 146 * 加密函数 147 */ 148 public function encode() 149 { 150 $this->encodeText($this->_sourceFile)->encodeTemplate()->write($this->_targetFile); 151 echo 'encode-----解密前文件:'.$this->_sourceFile.'-----解密后文件:'.$this->_targetFile.'-----ok<br/>'; 152 } 153 154 /** 155 * 解密函数 156 */ 157 public function decode() 158 { 159 $sourceFileContent = file_get_contents($this->_sourceFile); 160 $this->decodeTemplate($sourceFileContent)->write($this->_targetFile); 161 echo 'decode-----解密前文件:'.$this->_sourceFile.'-----解密后文件:'.$this->_targetFile.'-----ok<br/>'; 162 } 163} 164 165$e = new Encipher("login_2.php", "login_3.php"); 166$e->encode(); 167 168$e = new Encipher("login_3.php", "login_4.php"); 169$e->decode();
批量加密解密没有做
方式二:
1require_once "./doEncode.php"; 2 3$app = str_replace('\\', '/', dirname(__FILE__)); 4$encipher = new DoCodeLock($app."/test", $app."/test"); 5 6$encipher->encode();
doEncode.php
1<?php 2/** 3 * Created by PhpStorm. 4 * User: 25754 5 * Date: 2019/10/16 6 * Time: 9:32 7 */ 8 9class DoCodeLock 10{ 11 /** 12 * The file/path which you want to encode. 13 */ 14 public $source_file = ''; 15 16 /** 17 * The file/path which you want to save the encoded file/path. 18 */ 19 public $encoded_file = ''; 20 21 /** 22 * Default comments. 23 */ 24 public $comments = array( 25 'Author: Yang', 26 'Email: 1017836267@qq.com' 27 ); 28 29 /** 30 * advanced encryption 31 */ 32 public $advancedEncryption = false; 33 34 /** 35 * variable name length. 36 */ 37 public $varnameLength = 8; 38 39 public function __construct($source_file = '', $encoded_file = '', $comments = array()) 40 { 41 !empty($source_file) && $this->source_file = $source_file; 42 !empty($encoded_file) && $this->encoded_file = $encoded_file; 43 !empty($comments) && $this->comments = (array)$comments; 44 45 if (empty($this->source_file) || !file_exists($this->source_file)) { 46 exit("Source file/path does not exist."); 47 } 48 if (empty($this->encoded_file) || !file_exists($this->encoded_file)) { 49 exit("Encoded file/path does not exist."); 50 } 51 } 52 53 public function encode() 54 { 55 list($paths, $files) = $this->_getPathsAndFiles($this->source_file); 56 $this->_createPaths($paths); 57 $this->_encryptFiles($files); 58 } 59 60 private function _getPathsAndFiles($dir) 61 { 62 $files = $paths = array(); 63 if (is_dir($dir)) { 64 $_files = scandir($dir); 65 foreach ($_files as $key => $file) { 66 if ($file == '.' || $file == '..') { 67 continue; 68 } 69 if (is_dir($dir . "/" . $file)) { 70 $paths[] = $file; 71 list($subPaths, $subFiles) = $this->_getPathsAndFiles($dir . "/" . $file); 72 $subPaths = $this->_addBasePath($subPaths, $file); 73 $subFiles = $this->_addBasePath($subFiles, $file); 74 $paths = array_merge($paths, $subPaths); 75 $files = array_merge($files, $subFiles); 76 } else { 77 $files[] = $file; 78 } 79 } 80 } elseif (is_file($dir)) { 81 $files[] = basename($dir); 82 } 83 return array($paths, $files); 84 } 85 86 private function _addBasePath($files, $base) 87 { 88 foreach ($files as $key => $file) { 89 $files[$key] = $base . "/" . $file; 90 } 91 return $files; 92 } 93 94 private function _createPaths($paths) 95 { 96 foreach ($paths as $path) { 97 !is_dir($this->encoded_file . "/" . $path) && mkdir($this->encoded_file . "/" . $path, 0700); 98 } 99 } 100 101 private function _encryptFiles($files) 102 { 103 foreach ($files as $file) { 104 if ($this->advancedEncryption) { 105 $this->_encryptFile($file); 106 } else { 107 $this->_setHumanUnreadable($file); 108 } 109 } 110 } 111 112 private function _setHumanUnreadable($file) 113 { 114 $code = $this->_getPHPCode($file); 115 $regVars = $this->_setVarName($this->_getMatchedVariables($code)); 116 list($usedFuncs, $funcChars) = $this->_getMatchedFunctions($code); 117 if (!empty($usedFuncs)) { 118 $_tmp = $this->_setVarName(array('funcStrVar' => ''), $regVars); 119 $funcStrVar = $_tmp['funcStrVar']; 120 $usedFuncMaps = $this->_setVarName($usedFuncs, $regVars); 121 $regVars = array_merge($usedFuncMaps, $regVars); 122 } else { 123 $usedFuncMaps = array(); 124 } 125 $funcVarDefCode = $this->_getFuncVarDefCode($usedFuncMaps, $funcChars, $funcStrVar); 126 $headers = array_map('trim', array_merge(array('<?php', '/*'), $this->comments, array('*/'))); 127 $enCode = implode("\r\n", $headers) . "\r\n" . $funcVarDefCode . strtr($code, $regVars); 128 $this->_saveEncryptFile($file, $enCode); 129 } 130 131 private function _encryptFile($file) 132 { 133 list($enkey, $dekey) = $this->_getKeyPairs(); 134 $baseCodeOfHostedCode = $this->_getBaseCodeOfHostedCode(); 135 $decodeCodeOfHostedCode = $this->_getDecodeCodeOfHostedCode($file, $enkey, $dekey); 136 $hostedCode = $baseCodeOfHostedCode . $decodeCodeOfHostedCode; 137 138 $regVars = $this->_setVarName($this->_getMatchedVariables($hostedCode)); 139 list($usedFuncs, $funcChars) = $this->_getMatchedFunctions($hostedCode); 140 if (!empty($usedFuncs)) { 141 $_tmp = $this->_setVarName(array('funcStrVar' => ''), $regVars); 142 $funcStrVar = $_tmp['funcStrVar']; 143 $usedFuncMaps = $this->_setVarName($usedFuncs, $regVars); 144 $regVars = array_merge($usedFuncMaps, $regVars); 145 } else { 146 $usedFuncMaps = array(); 147 } 148 149 //$prefixCode: define function name & base extra code. 150 $funcVarDefCode = $this->_getFuncVarDefCode($usedFuncMaps, $funcChars, $funcStrVar); 151 $prefixCode = preg_replace("/\r|\n|\s+/is", "", $funcVarDefCode . strtr($baseCodeOfHostedCode, $regVars)); 152 153 $headers = array_map('trim', array_merge(array('<?php', '/*'), $this->comments, array('*/'))); 154 $hookKey = strtr(md5(implode("\r\n", $headers) . "\r\n" . $prefixCode), $enkey, $dekey); 155 $evalEmbedCode = $this->_getEvalEmbedCode($decodeCodeOfHostedCode, $regVars, $enkey, $dekey); 156 /** 157 * eval(base64_decode( 158 * str_replace("\$hookKey", '', strtr($hookKey.$evalEmbedCode, $dekey, $enkey)) 159 * )); 160 * $unset; 161 */ 162 $unset = 'unset(' . $funcStrVar; 163 foreach ($regVars as $var) { 164 $unset .= ',' . $var; 165 } 166 $unset .= ');'; 167 $evalCode = "@eval(" . $regVars["base64_decode"] . "(" . $regVars["str_replace"] . "(" . $regVars["\$hookKey"] . ",''," . $regVars["strtr"] . "('" . $hookKey . $evalEmbedCode . "','" . $dekey . "','" . $enkey . "'))));" . $unset; 168 $originalEncodedCode = $this->_getPHPEncode($file, $enkey, $dekey); 169 $enCode = implode("\r\n", $headers) . "\r\n" . $prefixCode . $evalCode . "return;?>\r\n" . $originalEncodedCode; 170 $this->_saveEncryptFile($file, $enCode, $enkey, $dekey); 171 } 172 173 /** 174 * The encoded code needs extra code 175 */ 176 private function _getBaseCodeOfHostedCode() 177 { 178 $code = <<<EOT 179 \$farrs = file(str_replace('\\\\', '/', __FILE__)); 180 \$enCode = array_pop(\$farrs); 181 \$phpCode = array_pop(\$farrs); 182 \$fstrs = implode('', \$farrs) . substr(\$phpCode, 0, strrpos(\$phpCode, '@ev')); 183 \$hookKey = md5(\$fstrs); 184 \$farrs = \$phpCode = \$fstrs = NULL; 185EOT; 186 return $code; 187 } 188 189 /** 190 * The encoded code needs decode code 191 * if the licence is generated, also need to process it. 192 */ 193 private function _getDecodeCodeOfHostedCode($file, $enkey, $dekey) 194 { 195 $code = <<<EOT 196 eval(base64_decode(strtr(\$enCode, '{$dekey}', '{$enkey}'))); 197 \$enCode = NULL; 198EOT; 199 return $code; 200 } 201 202 private function _getFuncVarDefCode($usedFuncMaps, $funcChars, $funcStrVar) 203 { 204 //all the chars of function name 205 $funcStr = implode("", $funcChars); 206 207 //set variable name's value for each variable of function name 208 $funcVarValArr = $this->_getFuncVarvalArr($usedFuncMaps, $funcChars, $funcStrVar); 209 210 //encoded code define function name string. 211 $code = $funcStrVar . "='{$funcStr}';"; 212 foreach ($usedFuncMaps as $func => $val) { 213 $code .= $val . "= " . $funcVarValArr[$func] . ";\n"; 214 } 215 return $code; 216 } 217 218 private function _getEvalEmbedCode($decodeCodeOfHostedCode, $regVars, $enkey, $dekey) 219 { 220 $code = preg_replace("/\r|\n/is", "", strtr($decodeCodeOfHostedCode, $regVars)); 221 //replace multi space to one, and encode it via base64 222 $code = base64_encode(preg_replace("/\s{2,}/is", " ", $code)); 223 $code = strtr($code, $enkey, $dekey); 224 return $code; 225 } 226 227 /** 228 * get function names and chars for all functions 229 */ 230 private function _getMatchedFunctions($code) 231 { 232 //match all function name 233 preg_match_all("/([a-z_0-9]+)\(/is", $code, $matches); 234 $usedFuncs = array_unique($matches[1]); 235 if (false !== ($key = array_search('eval', $usedFuncs))) { 236 unset($usedFuncs[$key]); 237 } 238 239 $funcChars = array_unique(preg_split("//is", implode("", $usedFuncs), -1, PREG_SPLIT_NO_EMPTY)); 240 shuffle($funcChars); 241 return array(array_flip($usedFuncs), $funcChars); 242 } 243 244 /** 245 * get variable names 246 */ 247 private function _getMatchedVariables($code) 248 { 249 preg_match_all("/(\\\$[a-z0-9]+)\s*\=/is", $code, $matches); 250 return array_flip($matches[1]); 251 } 252 253 private function _getFuncVarvalArr($usedFuncMaps, $funcChars, $funcStrVar) 254 { 255 $funcVarValArr = array(); 256 foreach ($usedFuncMaps as $func => $_val) { 257 $val = ""; 258 for ($i = 0, $len = strlen($func); $i < $len; $i++) { 259 if ($val == "") { 260 $val = $funcStrVar . "{" . array_search($func{$i}, $funcChars) . "}"; 261 } else { 262 $val = $val . "." . $funcStrVar . "{" . array_search($func{$i}, $funcChars) . "}"; 263 } 264 } 265 $funcVarValArr[$func] = $val; 266 } 267 return $funcVarValArr; 268 } 269 270 /** 271 * get php pure code, trim php tag 272 */ 273 private function _getPHPCode($file) 274 { 275 $from = $this->source_file . '/' . $file; 276 $str = file_get_contents($from); 277 $str = preg_replace("/^[\s\xef\xbb\xbf]*<\?php/is", "", $str); 278 $str = trim(preg_replace("/\?>\s*$/is", "", $str)); 279 return $str; 280 } 281 282 /** 283 * get php encoded code 284 */ 285 private function _getPHPEncode($file, $enkey, $dekey) 286 { 287 $code = $this->_getPHPCode($file); 288 $enCode = strtr(base64_encode($code), $enkey, $dekey); 289 return $enCode; 290 } 291 292 private function _getKeyPairs() 293 { 294 $enkey = $this->_getKeyStr(); 295 $dekey = $this->_getKeyStr(); 296 while ($enkey === $dekey) { 297 $dekey = $this->_getKeyStr(); 298 } 299 return array($enkey, $dekey); 300 } 301 302 private function _getKeyStr() 303 { 304 $base64str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 305 for ($i = 127; $i <= 160; $i++) { 306 $base64str .= chr($i); 307 } 308 $baseChars = array_filter(preg_split("//is", $base64str)); 309 $baseChars[] = 0; 310 shuffle($baseChars); 311 return implode("", $baseChars); 312 } 313 314 private function _setVarName($funcs, $filter = array()) 315 { 316 $length = $this->varnameLength; 317 $basestr = $this->_getInvisibleStr($length); 318 $count = count($funcs); 319 if ($count == 0) { 320 return array(); 321 } 322 $varArr = array(); 323 do { 324 $randStr = substr("\$" . str_shuffle($basestr), 0, rand(2, $length)); 325 if (!in_array($randStr, $varArr) && !in_array($randStr, $filter)) { 326 $varArr[] = $randStr; 327 $count--; 328 } 329 } while ($count > 0); 330 return array_combine(array_keys($funcs), $varArr); 331 } 332 333 /** 334 * legal variable names: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' 335 * Invisiable string's ascii is from 127 to 255:'[\x7f-\xff][\x7f-\xff]*' 336 * param $length the variable name's length. 337 */ 338 private function _getInvisibleStr($length = 10) 339 { 340 $str = ''; 341 for ($i = 0; $i < $length; $i++) { 342 $num = rand(127, 255); 343 $str .= chr($num); 344 } 345 return $str; 346 } 347 348 private function _saveEncryptFile($file, $enCode, $enkey = null, $dekey = null) 349 { 350 $to = $this->encoded_file . '/' . $file; 351 file_put_contents($to, $enCode); 352 echo $to . "\n"; 353 } 354}
