php代码加密怎么解密?

$key?=?"This?is?supposed?to?be?a?secret?key?!!!";?

function?keyED($txt,$encrypt_key)?

{?

$encrypt_key?=?md5($encrypt_key);?

$ctr=0;?

$tmp?=?"";?

for?($i=0;$i<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)?

{?

srand((double)microtime()*1000000);?

$encrypt_key?=?md5(rand(0,32000));?

$ctr=0;?

$tmp?=?"";?

for?($i=0;$i<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<strlen($txt);$i++)?{?

$md5?=?substr($txt,$i,1);?

$i++;?

$tmp.=?(substr($txt,$i,1)?^?$md5);?

}?

return?$tmp;?

}?

$string?=?"Hello?World?!!!";?

//?encrypt?$string,?and?store?it?in?$enc_text?

$enc_text?=?encrypt($string,$key);?

//?decrypt?the?encrypted?text?$enc_text,?and?store?it?in?$dec_text?

$dec_text?=?decrypt($enc_text,$key);?

//加密

function?str2hex($s)

{

$r?=?"";

$hexes?=?array?("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");

for?($i=0;?$i<strlen($s);?$i++)=""?$r?.=?($hexes?[(ord($s{$i})?>>?4)]?.?$hexes?[(ord($s{$i})?&?0xf)]);

return?$r;

}

//解密

function?hex2str($s)

{

$r?=?"";

for?(?$i?=?0;?$i<strlen($s);?$i=""?+="2)"?{

$x1?=?ord($s{$i});

$x1?=?($x1>=48?&&?$x1<58)$x1-48?:?$x1-97+10;

$x2?=?ord($s{$i+1});

$x2?=?($x2>=48?&&?$x2<58)$x2-48?:?$x2-97+10;

$r?.=?chr((($x1?<<?4)?&?0xf0)?|?($x2?&?0x0f));

}

return?$r;

}?

echo?str2hex("山东");

echo?"

";

echo?hex2str("c9bdb6ab");

>