Skip to content

js base64 迅雷地址破解 解决中文问题

迅雷的地址是基于base64编码的,首先在原链接的头尾,加上AA和ZZ,然后一起进行base64编码,完成后添加头部thunder://,举个例子:

假设链接是:
http://www.boydwang.com

先添加AA,ZZ得到:
AAhttp://www.boydwang.comZZ

然后进行base64编码得到:
QUFodHRwOi8vd3d3LmJveWR3YW5nLmNvbVpa

最后加上头部即可得到迅雷链接:
thunder://QUFodHRwOi8vd3d3LmJveWR3YW5nLmNvbVpa

下面来说说解码,迅雷已经写好了base64的编解码方法,并实现了迅雷地址编码,js文件路径在
http://pstatic.xunlei.com/js/base64.js
可以直接通过script标签引用或者保存到本地调用,但是它没有提供地址解码,这里实现了解码方法,解决中文编码问题:

前尖括号script type="text/javascript" src="http://pstatic.xunlei.com/js/base64.js"后尖括号前尖括号/script后尖括号
function utf8to16(str) {
    var out, i, len, c;
    var char2, char3;

    out = "";
    len = str.length;
    i = 0;
    while(i < len) {
    c = str.charCodeAt(i++);
    switch(c >> 4)
    { 
      case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
        // 0xxxxxxx
        out += str.charAt(i-1);
        break;
      case 12: case 13:
        // 110x xxxx   10xx xxxx
        char2 = str.charCodeAt(i++);
        out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
        break;
      case 14:
        // 1110 xxxx  10xx xxxx  10xx xxxx
        char2 = str.charCodeAt(i++);
        char3 = str.charCodeAt(i++);
        out += String.fromCharCode(((c & 0x0F) << 12) |
                       ((char2 & 0x3F) << 6) |
                       ((char3 & 0x3F) << 0));
        break;
    }
    }

    return out;
}

function ThunderDecode(t_url){
	var thunderTitle = "thunder://";
	t_url = t_url.substring(thunderTitle.length);
	var temp = decode64(t_url);//decode64为base64.js中提供的方法
	temp = temp.substring(2, temp.length - 2);//去掉头尾的AA ZZ
	return utf8to16(temp);
}
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x