<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_66313"> <div class="blockcode"> <div id="code_Aw4"><ol> <li><?php<li> <li>class SysCrypt {<li> <li>private $crypt_key;<li> <li>// 构造函数<li>public function __construct($crypt_key) {<li> $this -> crypt_key = $crypt_key;</li> <li>}</li> <li> </li> <li>public function php_encrypt($txt) {</li> <li> srand((double)microtime() * 1000000);</li> <li> $encrypt_key = md5(rand(0,32000));</li> <li> $ctr = 0;</li> <li> $tmp = '';</li> <li> for($i = 0;$i<strlen($txt);$i ) {<li> $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;<li> $tmp .= $encrypt_key[$ctr].($txt[$i]^$encrypt_key[$ctr ]);<li> }<li> return base64_encode(self::__key($tmp,$this -> crypt_key));</li> <li>}</li> <li> </li> <li>public function php_decrypt($txt) {</li> <li> $txt = self::__key(base64_decode($txt),$this -> crypt_key);</li> <li> $tmp = '';</li> <li> for($i = 0;$i < strlen($txt); $i ) {<li> $md5 = $txt[$i];<li> $tmp .= $txt[ $i] ^ $md5;<li> }<li> return $tmp;<li>}<li> <li>private function __key($txt,$encrypt_key) {<li> $encrypt_key = md5($encrypt_key);<li> $ctr = 0;<li> $tmp = '';<li> for($i = 0; $i < strlen($txt); $i ) {<li> $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;<li> $tmp .= $txt[$i] ^ $encrypt_key[$ctr ];<li> }<li> return $tmp;<li>}<li> <li>public function __destruct() {<li> $this -> crypt_key = null;</li> <li>}</li> <li>}</li> <li> </li> <li> </li> <li>$sc = new SysCrypt('phpwms');</li> <li>$text = '110';</li> <li>print($sc -> php_encrypt($text));</li> <li>print('<br>');</li> <li>print($sc -> php_decrypt($sc -> php_encrypt($text)));</li> <li>?></li> </ol></div> <em onclick="copycode($('code_Aw4'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> 암호화 및 복호화, PHP</div> <div id="comment_66313" class="cm"> </div> <div id="post_rate_div_66313"></div> <br><br>