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. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
常见问题
相关文章
猜你喜欢
- PHP7中对十六进制字符串处理的问题详解 2023-04-10
- PHP 添加水印 & 比例缩略图 & 固定高度 & 固定宽度 类。 2023-04-06
- PHP 远程图片获取到本地 2023-04-06
- 一个很好的PHP验证类 2023-04-06
- PHP 文件本身操作 2023-04-06
- PHP目录操作 2023-04-06
- PHP 文件的基本操作 2023-04-06
- PHP的文件操作 2023-04-06
- php 把汉字转换为拼音 2023-04-06
- PHP 获取IP地址 2023-04-06
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.