2021-10-07

此处仅作记录。

 

<?php
function rc4($pwd, $data){
    $key[] ="";
    $box[] ="";
    $pwd_length = strlen($pwd);
    $data_length = strlen($data);
    for ($i = 0; $i < 256; $i++)
    {
        $key[$i] = ord($pwd[$i % $pwd_length]);
        $box[$i] = $i;
    }
    for ($j = $i = 0; $i < 256; $i++)
    {
        $j = ($j + $box[$i] + $key[$i]) % 256;
        $tmp = $box[$i];
        $box[$i] = $box[$j];
        $box[$j] = $tmp;
    }
    for ($a = $j = $i = 0; $i < $data_length; $i++)
    {
        $a = ($a + 1) % 256;
        $j = ($j + $box[$a]) % 256;

        $tmp = $box[$a];
        $box[$a] = $box[$j];
        $box[$j] = $tmp;

        $k = $box[(($box[$a] + $box[$j]) % 256)];
        $cipher .= chr(ord($data[$i]) ^ $k);
    }
    return $cipher;
}

function AES_encode($str, $key){
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND);
        print_r(MCRYPT_MODE_ECB);
        return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB, $iv);
}

function AES_decode($str, $key){
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND);
        return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB, $iv);
}

function getEP($sk, $ctype) {
        $pkey = "b45197d21f17bb8a"; //21
        if ($ctype == 20) $pkey = "9e3633aadde6bfec"; //20
        else if ($ctype == 30) $pkey = "197d21f1722361ac"; //30
        $ep = urlencode(base64_encode(AES_encode($sk, $pkey)));
        return trim($ep);
}

$sk = isset($_REQUEST['sk']) ? trim($_REQUEST['sk']) : "";
$ctype = isset($_REQUEST['ctype']) ? intval($_REQUEST['ctype']) : 30;
if (strlen($sk) < 5) die('{"ep":""}');
echo '{"ep":"'.getEP($sk, $ctype).'"}';
?>

 

打赏

好文章,更需要你的鼓励

本文由 氢设计 创作,除注明转载/出处外,均为本站原创,转载前请务必署名

最后编辑时间为:2021-11-23 10:21:01

本文链接:https://www.h2sheji.com/show-95.html