国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

PHP實現的加密解密處理類

2020-03-22 19:04:51
字體:
來源:轉載
供稿:網友
= GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991) =------------------------------------------------------------ = 文件名稱:cls.sys_crypt.php = 摘 要:php加密解密處理類 = 版 本:1.0 = 參 考:Discuz論壇的passport相關函數 =------------------------------------------------------------ = 最后更新日期:2007-12-09 ============================================================*/ html' target='_blank'>class SysCrypt { private $crypt_key; // 構造函數 public function __construct($crypt_key) { $this - crypt_key = $crypt_key; public function php_encrypt($txt) { srand((double)microtime() * 1000000); $encrypt_key = md5(rand(0,32000)); $ctr = 0; $tmp = ''; for($i = 0;$i strlen($txt);$i++) { $ctr = $ctr == strlen($encrypt_key) 0 : $ctr; $tmp .= $encrypt_key[$ctr].($txt[$i]^$encrypt_key[$ctr++]); return base64_encode(self::__key($tmp,$this - crypt_key)); public function php_decrypt($txt) { $txt = self::__key(base64_decode($txt),$this - crypt_key); $tmp = ''; for($i = 0;$i strlen($txt); $i++) { $md5 = $txt[$i]; $tmp .= $txt[++$i] ^ $md5; return $tmp; private function __key($txt,$encrypt_key) { $encrypt_key = md5($encrypt_key); $ctr = 0; $tmp = ''; for($i = 0; $i strlen($txt); $i++) { $ctr = $ctr == strlen($encrypt_key) 0 : $ctr; $tmp .= $txt[$i] ^ $encrypt_key[$ctr++]; return $tmp; public function __destruct() { $this - crypt_key = null; //執行代碼 $sc = new SysCrypt('phpwms'); $text = 'abc10000008910000000990099hh'; //需要加密的數據 print($sc - php_encrypt($text)); //加密 print(' br print($sc - php_decrypt($sc - php_encrypt($text))); //解密
更多關于PHP相關內容可查看本站專題:《php加密方法總結》、《PHP運算與運算符用法總結》、《PHP網絡編程技巧總結》、《PHP基本語法入門教程》、《php操作office文檔技巧總結(包括word,excel,access,ppt)》、《php日期與時間用法總結》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》希望本文所述對大家PHP程序設計有所幫助。PHP教程

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丽江市| 泸西县| 平昌县| 玉龙| 四子王旗| 陕西省| 乌海市| 子长县| 景泰县| 吴旗县| 昭苏县| 江西省| 始兴县| 雅江县| 修水县| 鸡东县| 盱眙县| 浮梁县| 肇东市| 淳化县| 商水县| 东台市| 金川县| 靖远县| 满洲里市| 龙里县| 镶黄旗| 遂昌县| 景德镇市| 松桃| 南投市| 区。| 观塘区| 花莲市| 阜康市| 井冈山市| 黔西| 广宗县| 平度市| 吉首市| 西安市|