您现在的位置是:首页 >

php普通加密解密 php加密解密处理类--参 考:Discuz论坛的passpor

火烧 2022-12-18 02:24:00 1056
h 加密解密处理类--参 考:Di cuz论坛的 a or cla Sy Cry t { rivate$cry t_key // 构造函数 u licfu ctio __co truct $cry
php普通加密解密 php加密解密处理类--参 考:Discuz论坛的passpor

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  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码