国产探花免费观看_亚洲丰满少妇自慰呻吟_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教程

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 工布江达县| 分宜县| 洞头县| 孝感市| 分宜县| 沙洋县| 义马市| 彝良县| 上林县| 云霄县| 彩票| 行唐县| 临高县| 甘孜| 兖州市| 观塘区| 赣州市| 东乌珠穆沁旗| 措美县| 德庆县| 青川县| 福鼎市| 长岭县| 高阳县| 桦南县| 勃利县| 宜章县| 万全县| 兴隆县| 武川县| 信丰县| 临湘市| 桃园县| 交口县| 胶南市| 玉环县| 台湾省| 灯塔市| 舒兰市| 东兰县| 湟中县|