美拍视频地址解析

1.获取base64加密后的url,
美拍视频地址解析_第1张图片

2.解密url

     var h = "substring",
    i = "split",
    j = "replace",
    k = "substr";
    function  getHex(a) {
            return {
                str: a[h](4),
                hex: a[h](0, 4)[i]("").reverse().join("")
            }
        }
     function getDec(a) {
            var b = parseInt(a, 16).toString();
            return {
                pre: b[h](0, 2)[i](""),
                tail: b[h](2)[i]("")
            }
        }
        function substr(a, b) {
            var c = a[h](0, b[0]),
            d = a[k](b[0], b[1]);
            return c + a[h](b[0])[j](d, "")
        }
       function  getPos(a, b) {
            return b[0] = a.length - b[0] - b[1],
            b
        }
        function decode(a) {

            var b = getHex(a),
            c = getDec(b.hex),
            d = substr(b.str, c.pre);
            return new Buffer(substr(d, getPos(d, c.tail)),'base64').toString()
        }
        var url = decode(上面获取到的加密后的url)

你可能感兴趣的:(js)