//---------------以下为加密函数(复制过去就行了)-----------------
function
keyED(
$txt
,
$encrypt_key
){
$encrypt_key
= md5(
$encrypt_key
);
$ctr
=0;
$tmp
=
""
;
for
(
$i
=0;
$i
<</code>
strlen
(
$txt
);
$i
++)
{
if
(
$ctr
==
strlen
(
$encrypt_key
))
$ctr
=0;
$tmp
.=
substr
(
$txt
,
$i
,1) ^
substr
(
$encrypt_key
,
$ctr
,1);
$ctr
++;
}
return
$tmp
;
}
function
encrypt(
$txt
,
$key
) {
$encrypt_key
= md5(mt_rand(0,100));
$ctr
=0;
$tmp
=
""
;
for
(
$i
=0;
$i
<</code>
strlen
(
$txt
);
$i
++)
{
if
(
$ctr
==
strlen
(
$encrypt_key
))
$ctr
=0;
$tmp
.=
substr
(
$encrypt_key
,
$ctr
,1) . (
substr
(
$txt
,
$i
,1) ^
substr
(
$encrypt_key
,
$ctr
,1));
$ctr
++;
}
return
keyED(
$tmp
,
$key
);
}
function
decrypt(
$txt
,
$key
){
$txt
= keyED(
$txt
,
$key
);
$tmp
=
""
;
for
(
$i
=0;
$i
<</code>
strlen
(
$txt
);
$i
++)
{
$md5
=
substr
(
$txt
,
$i
,1);
$i
++;
$tmp
.= (
substr
(
$txt
,
$i
,1) ^
$md5
);
}
return
$tmp
;
}
function
encrypt_url(
$url
,
$key
){
return
rawurlencode(
base64_encode
(encrypt(
$url
,
$key
)));
}
function
decrypt_url(
$url
,
$key
){
return
decrypt(
base64_decode
(rawurldecode(
$url
)),
$key
);
}
function
geturl(
$str
,
$key
){
$str
= decrypt_url(
$str
,
$key
);
$url_array
=
explode
(
'&'
,
$str
);
if
(
is_array
(
$url_array
))
{
foreach
(
$url_array
as
$var
)
{
$var_array
=
explode
(
"="
,
$var
);
$vars
[
$var_array
[0]]=
$var_array
[1];
}
}
return
$vars
;
}
//---------------以上为加密函数-结束(复制过去就行了)-----------------
原文链接:https://www.cnblogs.com/lxwphp/p/15454991.html
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/18559