PHP實現加強版加密解密類執行個體,加強版加密解密_PHP教程

來源:互聯網
上載者:User

PHP實現加強版加密解密類執行個體,加強版加密解密


本文執行個體講述了PHP實現加強版加密解密類。分享給大家供大家參考。具體如下:

<?phpclass Ender{  private $enkey;//加密解密用的密鑰  private $rep_char='#';  //替換加密後的base64字串中的=,因為=在有些場合是禁止使用的,  //這裡可以用一個允許的字元作為替換。  //構造參數是密鑰  public function __construct($key=''){    if(!$key){      $this->enkey=$key;    }  }  //設定密鑰http://blog.ddian.cn  public function set_key($key){    $this->enkey=$key;  }  private function keyED($txt,$encrypt_key)   {   $encrypt_key = md5($encrypt_key);   $ctr=0;   $tmp = "";   for ($i=0;$ienkey;  }  srand((double)microtime()*1000000);   $encrypt_key = md5(rand(0,32000));   $ctr=0;   $tmp = "";   for ($i=0;$ikeyED($tmp,$key));  $r=str_replace('=',$this->rep_char,$r);  return $r;   }  //解密字串  public function decrypt($txt,$key='')   {  $txt=str_replace($this->rep_char,'=',$txt);  $txt=base64_decode($txt);  if(!$key){      $key=$this->enkey;  }  $txt = $this->keyED($txt,$key);   $tmp = "";   for ($i=0;$i

希望本文所述對大家的php程式設計有所協助。

http://www.bkjia.com/PHPjc/1039209.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1039209.htmlTechArticlePHP實現加強版加密解密類執行個體,加強版加密解密 本文執行個體講述了PHP實現加強版加密解密類。分享給大家供大家參考。具體如下: phpclass E...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.