To find the corresponding cryptographic function of a decryption function
This post was last edited by xuzuning on 2013-02-21 10:07:35
Now known as a decryption function (Readkey), the corresponding cryptographic function is
function Authcode ($string, $operation = "DECODE", $key = "", $expiry = 0)
{
$ckey _length = 4;
$key = MD5 ($key! = ""? $key: "A2264DXLUPVMLKQR");
$keya = MD5 (substr ($key, 0, 16));
$KEYB = MD5 (substr ($key, 16, 16));
$KEYC = $ckey _length? $operation = = "DECODE"? substr ($string, 0, $ckey _length): substr (MD5 (Microtime ()), 0-$ckey _length): "";
$cryptkey = $keya. MD5 ($keya. $KEYC);
$key _length = strlen ($cryptkey);
$string = $operation = = "DECODE"? Base64_decode (substr ($string, $ckey _length)): sprintf ("%010d", $expiry? $expiry + Time (): 0). substr (MD5 ($strin G. $keyb), 0, (+). $string;
$string _length = strlen ($string);
$result = "";
$box = Range (0, 255);
$rndkey = Array ();
$i = 0;
for (; $i <= 255;++ $i)
{
$rndkey [$i] = Ord ($cryptkey [$i% $key _length]);
}
$j = $i = 0;
for (; $i < 256;++ $i)
{
$j = ($j + $box [$i] + $rndkey [$i])% 256;
$tmp = $box [$i];
$box [$i] = $box [$j];
$box [$j] = $tmp;
}
$a = $j = $i = 0;
for (; $i < $string _length;++ $i)
{
$a = ($a + 1)% 256;
$j = ($j + $box [$a])% 256;
$tmp = $box [$a];
$box [$a] = $box [$j];
$box [$j] = $tmp;
$result. = Chr (ord ($string [$i]) ^ $box [($box [$a] + $box [$j])% 256]);
}
if ($operation = = "DECODE")
{
if (substr ($result, 0, ten) = = 0 | | 0 < substr ($result, 0, Ten)-time ()) && substr ($result, 10, 16) = = substr (MD5 ($result, 0, 16))
{
Return substr ($result, 26);
}
Return "";
}
Return $KEYC. Str_replace ("=", "", Base64_encode ($result));
}
function Readkey ($keys)
{
$Leskey = Authcode ($keys, "DECODE", "A2264DXLUPVMLKQR");
$Leskey = Base64_decode ($Leskey);
$FIRSTSTR = substr ($Leskey, 0, 1);
$Leskey = substr ($Leskey, 1);
$Leskey = Strrev (substr ($Leskey, 0, $FIRSTSTR)). Chr (Ord (substr ($Leskey, $FIRSTSTR, 1)) ^ $firstStr). Strrev (Subs TR ($Leskey, $FIRSTSTR + 1));