您现在的位置是:首页
>
php普通加密解密 php加密解密处理类--参 考:Discuz论坛的passpor
h 加密解密处理类--参 考:Di cuz论坛的 a or cla Sy Cry t { rivate$cry t_key // 构造函数 u licfu ctio __co truct $cry

php加密解密处理类--参 考:Discuz论坛的passpor
classSysCrypt { private$crypt_key; // 构造函数 publicfunction__construct($crypt_key) { $this > crypt_key = $crypt_key; } publicfunctionphp_encrypt($txt) { srand((double)microtime() * ); $encrypt_key= md (rand( )); $ctr= ; $tmp= ; for($i= ;$i<strlen($txt);$i++) { $ctr= $ctr== strlen($encrypt_key) ? : $ctr; $tmp = $encrypt_key[$ctr] ($txt[$i]^$encrypt_key[$ctr++]); } returnbase _encode(self::__key($tmp$this > crypt_key)); } publicfunctionphp_decrypt($txt) { $txt= self::__key(base _decode($txt) $this > crypt_key); $tmp= ; for($i= ;$i< strlen($txt); $i++) { $md = $txt[$i]; $tmp = $txt[++$i] ^ $md ; } return$tmp; } privatefunction__key($txt$encrypt_key) { $encrypt_key= md ($encrypt_key); $ctr= ; $tmp= ; for($i= ; $i< strlen($txt); $i++) { $ctr= $ctr== strlen($encrypt_key) ? : $ctr; $tmp = $txt[$i] ^ $encrypt_key[$ctr++]; } return$tmp; } publicfunction__destruct() { $this > crypt_key = null; } } $sc= newSysCrypt( phpwms ); $text= ; print($sc > php_encrypt($text)); print( <br> ); print($sc > php_decrypt($sc > php_encrypt($text))); ?> lishixinzhi/Article/program/PHP/201311/21324 很赞哦! (1056)