/**
- 加密函数
- @param string $txt 需要加密的字符串
- @param string $key 密钥
- @return string 返回加密结果
/
function encrypt($txt, KaTeX parse error: Expected '}', got 'EOF' at end of input: …'){ if (empty(txt)) return t x t ; i f ( e m p t y ( txt; if (empty( txt;if(empty(key)) $key = md5(MD5_KEY);
$chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.”;
$ikey ="-x6g6ZWm2G9g_vr0Bo.pOq3kRIxsZ6rm";
$nh1 = rand(0,64);
$nh2 = rand(0,64);
$nh3 = rand(0,64);
$ch1 = KaTeX parse error: Expected '}', got 'EOF' at end of input: chars{nh1};
$ch2 = KaTeX parse error: Expected '}', got 'EOF' at end of input: chars{nh2};
$ch3 = KaTeX parse error: Expected '}', got 'EOF' at end of input: chars{nh3};
$nhnum = $nh1 + $nh2 + $nh3;
k n u m = 0 ; knum = 0; knum=0;i = 0;
while(isset(KaTeX parse error: Expected '}', got 'EOF' at end of input: key{i})) k n u m + = o r d ( knum +=ord( knum+=ord(key{$i++});
m d K e y = s u b s t r ( m d 5 ( m d 5 ( m d 5 ( mdKey = substr(md5(md5(md5( mdKey=substr(md5(md5(md5(key. c h 1 ) . ch1). ch1).ch2. i k e y ) . ikey). ikey).ch3), n h n u m nhnum%8, nhnumknum%8 + 16);
KaTeX parse error: Expected group after '_' at position 29: …encode(time().'_̲'.txt);
KaTeX parse error: Expected group after '_' at position 49: …='),array('-','_̲','.'),txt);
$tmp = ‘’;
j = 0 ; j=0; j=0;k = 0;
t l e n = s t r l e n ( tlen = strlen( tlen=strlen(txt);
k l e n = s t r l e n ( klen = strlen( klen=strlen(mdKey);
for ($i=0; i < i< i<tlen; $i++) {
$k = $k == $klen ? 0 : $k;
j = ( j = ( j=(nhnum+strpos( c h a r s , chars, chars,txt{KaTeX parse error: Expected 'EOF', got '}' at position 2: i}̲)+ord(mdKey{$k++}))%64;
$tmp .= KaTeX parse error: Expected '}', got 'EOF' at end of input: chars{j};
}
t m p l e n = s t r l e n ( tmplen = strlen( tmplen=strlen(tmp);
t m p = s u b s t r r e p l a c e ( tmp = substr_replace( tmp=substrreplace(tmp, c h 3 , ch3, ch3,nh2 % ++$tmplen,0);
t m p = s u b s t r r e p l a c e ( tmp = substr_replace( tmp=substrreplace(tmp, c h 2 , ch2, ch2,nh1 % ++$tmplen,0);
t m p = s u b s t r r e p l a c e ( tmp = substr_replace( tmp=substrreplace(tmp, c h 1 , ch1, ch1,knum % ++$tmplen,0);
return $tmp;
}
/* - 解密函数
- @param string $txt 需要解密的字符串
- @param string $key 密匙
- @return string 字符串类型的返回结果
*/
function decrypt($txt, $key = ‘’, KaTeX parse error: Expected '}', got 'EOF' at end of input: …0){ if (empty(txt)) return t x t ; i f ( e m p t y ( txt; if (empty( txt;if(empty(key)) $key = md5(MD5_KEY);
$chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.";
$ikey ="-x6g6ZWm2G9g_vr0Bo.pOq3kRIxsZ6rm";
k n u m = 0 ; knum = 0; knum=0;i = 0;
t l e n = @ s t r l e n ( tlen = @strlen( tlen=@strlen(txt);
while(isset(KaTeX parse error: Expected '}', got 'EOF' at end of input: key{i})) k n u m + = o r d ( knum +=ord( knum+=ord(key{$i++});
c h 1 = @ ch1 = @ ch1=@txt{$knum % $tlen};
n h 1 = s t r p o s ( nh1 = strpos( nh1=strpos(chars,$ch1);
t x t = @ s u b s t r r e p l a c e ( txt = @substr_replace( txt=@substrreplace(txt,’’,$knum % $tlen–,1);
c h 2 = @ ch2 = @ ch2=@txt{$nh1 % $tlen};
n h 2 = @ s t r p o s ( nh2 = @strpos( nh2=@strpos(chars,$ch2);
t x t = @ s u b s t r r e p l a c e ( txt = @substr_replace( txt=@substrreplace(txt,’’,$nh1 % $tlen–,1);
c h 3 = @ ch3 = @ ch3=@txt{$nh2 % $tlen};
n h 3 = @ s t r p o s ( nh3 = @strpos( nh3=@strpos(chars,$ch3);
t x t = @ s u b s t r r e p l a c e ( txt = @substr_replace( txt=@substrreplace(txt,’’,$nh2 % $tlen–,1);
$nhnum = $nh1 + $nh2 + $nh3;
m d K e y = s u b s t r ( m d 5 ( m d 5 ( m d 5 ( mdKey = substr(md5(md5(md5( mdKey=substr(md5(md5(md5(key. c h 1 ) . ch1). ch1).ch2. i k e y ) . ikey). ikey).ch3), n h n u m nhnum % 8, nhnumknum % 8 + 16);
$tmp = ‘’;
$j=0; $k = 0;
t l e n = @ s t r l e n ( tlen = @strlen( tlen=@strlen(txt);
k l e n = @ s t r l e n ( klen = @strlen( klen=@strlen(mdKey);
for ($i=0; i < i< i<tlen; $i++) {
$k = $k == $klen ? 0 : $k;
j = s t r p o s ( j = strpos( j=strpos(chars,KaTeX parse error: Expected '}', got 'EOF' at end of input: txt{i})- n h n u m − o r d ( nhnum - ord( nhnum−ord(mdKey{KaTeX parse error: Expected 'EOF', got '}' at position 4: k++}̲); while (j<0) $j+=64;
$tmp .= KaTeX parse error: Expected '}', got 'EOF' at end of input: chars{j};
}
KaTeX parse error: Expected group after '_' at position 30: …ace(array('-','_̲','.'),array('+…tmp);
t m p = t r i m ( b a s e 6 4 d e c o d e ( tmp = trim(base64_decode( tmp=trim(base64decode(tmp));
if (preg_match("/\d{10}/s”,substr(KaTeX parse error: Expected '}', got 'EOF' at end of input: …1))){ if (ttl > 0 && (time() - substr($tmp,0,11) > $ttl)){
$tmp = null;
}else{
t m p = s u b s t r ( tmp = substr( tmp=substr(tmp,11);
}
}
return $tmp;
}