200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > PHP加解密函数

PHP加解密函数

时间:2022-08-10 15:50:11

相关推荐

PHP加解密函数

/**

加密函数@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 txt;if(empty(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;

knum=0;knum = 0;knum=0;i = 0;

while(isset(KaTeX parse error: Expected '}', got 'EOF' at end of input: key{i})) knum+=ord(knum +=ord(knum+=ord(key{$i++});

mdKey=substr(md5(md5(md5(mdKey = substr(md5(md5(md5(mdKey=substr(md5(md5(md5(key.ch1).ch1).ch1).ch2.ikey).ikey).ikey).ch3),nhnumnhnum%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;

tlen=strlen(tlen = strlen(tlen=strlen(txt);

klen=strlen(klen = strlen(klen=strlen(mdKey);

for ($i=0; i<i<i<tlen; $i++) {

$k = $k == $klen ? 0 : $k;

j=(j = (j=(nhnum+strpos(chars,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};

}

tmplen=strlen(tmplen = strlen(tmplen=strlen(tmp);

tmp=substrreplace(tmp = substr_replace(tmp=substrr​eplace(tmp,ch3,ch3,ch3,nh2 % ++$tmplen,0);

tmp=substrreplace(tmp = substr_replace(tmp=substrr​eplace(tmp,ch2,ch2,ch2,nh1 % ++$tmplen,0);

tmp=substrreplace(tmp = substr_replace(tmp=substrr​eplace(tmp,ch1,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 txt;if(empty(txt; if (empty(txt;if(empty(key)) $key = md5(MD5_KEY);

$chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.";

$ikey ="-x6g6ZWm2G9g_vr0Bo.pOq3kRIxsZ6rm";

knum=0;knum = 0;knum=0;i = 0;

tlen=@strlen(tlen = @strlen(tlen=@strlen(txt);

while(isset(KaTeX parse error: Expected '}', got 'EOF' at end of input: key{i})) knum+=ord(knum +=ord(knum+=ord(key{$i++});

ch1=@ch1 = @ch1=@txt{$knum % $tlen};

nh1=strpos(nh1 = strpos(nh1=strpos(chars,$ch1);

txt=@substrreplace(txt = @substr_replace(txt=@substrr​eplace(txt,’’,$knum % $tlen–,1);

ch2=@ch2 = @ch2=@txt{$nh1 % $tlen};

nh2=@strpos(nh2 = @strpos(nh2=@strpos(chars,$ch2);

txt=@substrreplace(txt = @substr_replace(txt=@substrr​eplace(txt,’’,$nh1 % $tlen–,1);

ch3=@ch3 = @ch3=@txt{$nh2 % $tlen};

nh3=@strpos(nh3 = @strpos(nh3=@strpos(chars,$ch3);

txt=@substrreplace(txt = @substr_replace(txt=@substrr​eplace(txt,’’,$nh2 % $tlen–,1);

$nhnum = $nh1 + $nh2 + $nh3;

mdKey=substr(md5(md5(md5(mdKey = substr(md5(md5(md5(mdKey=substr(md5(md5(md5(key.ch1).ch1).ch1).ch2.ikey).ikey).ikey).ch3),nhnumnhnum % 8,nhnumknum % 8 + 16);

$tmp = ‘’;

$j=0; $k = 0;

tlen=@strlen(tlen = @strlen(tlen=@strlen(txt);

klen=@strlen(klen = @strlen(klen=@strlen(mdKey);

for ($i=0; i<i<i<tlen; $i++) {

$k = $k == $klen ? 0 : $k;

j=strpos(j = strpos(j=strpos(chars,KaTeX parse error: Expected '}', got 'EOF' at end of input: txt{i})-nhnum−ord(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);

tmp=trim(base64decode(tmp = trim(base64_decode(tmp=trim(base64d​ecode(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{

tmp=substr(tmp = substr(tmp=substr(tmp,11);

}

}

return $tmp;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。