php加密解密处理类
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-07-25 08:42:28
asal
916 orang telah melayarinya
-
- 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 $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 $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 $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 = '110';
- print($sc -> php_encrypt($text));
- print('
');
- print($sc -> php_decrypt($sc -> php_encrypt($text)));
- ?>
复制代码
|
加密解密, php
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel terbaru oleh pengarang
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
Topik-topik yang berkaitan
Lagi>