php加密解密处理类

2023-03-20 0 762
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
 
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 = '110';
print($sc -> php_encrypt($text));
print('<br>');
print($sc -> php_decrypt($sc -> php_encrypt($text)));
?>

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!

2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!

3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!

4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有猫币奖励和额外收入!

5. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!

ER0学院 php 代码片段 php加密解密处理类 https://www.er0xy.com/2704.html

常见问题

相关文章

发表评论
1 条评论
2023年 5月 5日 上午2:30 回复

Your point of view caught my eye and was very interesting. Thanks. I have a question for you.

  • 0 +

    访问总数

  • 0 +

    会员总数

  • 0 +

    文章总数

  • 0 +

    今日发布

  • 0 +

    本周发布

  • 0 +

    运行天数

你的前景,远超我们想象