Home > Backend Development > PHP Tutorial > 用php改写百度mp3地址的加密模式

用php改写百度mp3地址的加密模式

WBOY
Release: 2016-06-13 13:03:03
Original
1080 people have browsed it

用php改写百度mp3地址的加密方式

百度mp3地址是加密过的,具体加密方式大家自己看吧.解码函数如下:

//copyright http://www.k686.com
 //author tuzwu58@gmail.com
                function decode(url){
                    var len = url.length;
                    var decurl = "";
                    var asc_arr1 = [], asc_arr2 = [];

                    var key = sertim % 26;
 
                  key = key ? key : 1;

                    function init(head, bottom, middle){
                        for (var i = head; i <= bottom; i++) {
                            asc_arr1[i] = i + middle;
                            asc_arr2[i + middle] = i;
                        }
                    }

                    init(0, 9, 48);
                    init(10, 35, 55);//http://www.k686.com
                    init(36, 61, 61);

                    for (var i = 0; i < len; i++) {
                        var word = url.charAt(i);
        if (/[A-Za-z0-9]/.test(word)) {
                            var pos = asc_arr2[url.charCodeAt(i)] - key;
                            if (pos < 0)
                                pos += 62;
                            word = String.fromCharCode(asc_arr1[pos]);
                        }
                        decurl += word;
                    }
                    return decurl;
                }
Copy after login

?

传入的字符串格式形如:

str = "o00w://333.osq.z0h0z.nv2.ju/q5/4p14phuzopN1hun/44zn977D7A9F8G-7A.twA";
var sertim = 1289225685;

?

两个变量需要带入到上面的函数,这样才能解析为一个标准的url地址.

?

下面是php改写后的:

 //copyright http://www.k686.com
 //author tuzwu58@gmail.com
                function decode($url,$sertim){
                    $len = strlen($url);
                    $decurl = "";
                    $asc_arr1 = array();
					$asc_arr2 = array();

                    $key = $sertim % 26;
 
                  $key = $key ? $key : 1;
//第1次 http://www.k686.com
                        for ($i = 0; $i <= 9; $i++) {
                            $asc_arr1[$i] = $i + 48;
                            $asc_arr2[$i + 48] = $i;
                        }
//第2次
                        for ($i = 10; $i <= 35; $i++) {
                            $asc_arr1[$i] = $i + 55;
                            $asc_arr2[$i + 55] = $i;
                        }
//第3次
                        for ($i = 36; $i <= 61; $i++) {
                            $asc_arr1[$i] = $i + 61;
                            $asc_arr2[$i + 61] = $i;
                        }
//end http://www.k686.com
                    for ($i = 0; $i < $len; $i++) {
                        $word = substr($url,$i,1);

        if (preg_match("/[A-Za-z0-9]/",$word)) {
                            $pos = $asc_arr2[ord(substr($url,$i,1))] - $key;
                            if ($pos < 0){
                                $pos += 62;
							}
                            $word = chr($asc_arr1[$pos]);
                        }
                        $decurl .= $word;
                    }

                    return $decurl;
                }
$str = 'o00w://333.osq.z0h0z.nv2.ju/q5/4p14phuzopN1hun/44zn977D7A9F8G-7A.twA';
$sertim = 1289225685;
echo decode($str,$sertim);
Copy after login

?

算是用php改写了js函数,功能是一模一样的.传入的两个参数都可以在百度mp3页面找得到的.

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template