• Js 之内容加密


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>js加密</title>
    </head>
    <body>
    
    <script>
        var str = "alert('hello js')";
        eval(jsEncode(str));
    
        /**
         * 加密函数
         * @param text 加密的内容
         * @param gv 加密token
         * @returns {string|string} 加密后的内容
         */
        function jsEncode(text, gv = 'Yang') {
            var r = "";
            var n;
            var t;
            var b = ["___", "__$", "_$_", "_$$", "$__", "$_$", "$$_", "$$$", "$___", "$__$", "$_$_", "$_$$", "$$__", "$$_$", "$$$_", "$$$$",];
            var s = "";
            for (var i = 0; i < text.length; i++) {
                n = text.charCodeAt(i);
                if (n == 0x22 || n == 0x5c) {
                    s += "\\\" + text.charAt(i).toString(16);
                } else if ((0x21 <= n && n <= 0x2f) || (0x3A <= n && n <= 0x40) || (0x5b <= n && n <= 0x60) || (0x7b <= n && n <= 0x7f)) {
                    //}else if( (0x20 <= n && n <= 0x2f) || (0x3A <= n == 0x40) || ( 0x5b <= n && n <= 0x60 ) || ( 0x7b <= n && n <= 0x7f ) ){
                    s += text.charAt(i);
                } else if ((0x30 <= n && n <= 0x39) || (0x61 <= n && n <= 0x66)) {
                    if (s) r += """ + s + ""+";
                    r += gv + "." + b[n < 0x40 ? n - 0x30 : n - 0x57] + "+";
                    s = "";
                } else if (n == 0x6c) { // 'l'
                    if (s) r += """ + s + ""+";
                    r += "(![]+"")[" + gv + "._$_]+";
                    s = "";
                } else if (n == 0x6f) { // 'o'
                    if (s) r += """ + s + ""+";
                    r += gv + "._$+";
                    s = "";
                } else if (n == 0x74) { // 'u'
                    if (s) r += """ + s + ""+";
                    r += gv + ".__+";
                    s = "";
                } else if (n == 0x75) { // 'u'
                    if (s) r += """ + s + ""+";
                    r += gv + "._+";
                    s = "";
                } else if (n < 128) {
                    if (s) r += """ + s;
                    else r += """;
                    r += "\\"+" + n.toString(8).replace(/[0-7]/g, function (c) {
                        return gv + "." + b[c] + "+"
                    });
                    s = "";
                } else {
                    if (s) r += """ + s;
                    else r += """;
                    r += "\\"+" + gv + "._+" + n.toString(16).replace(/[0-9a-f]/gi, function (c) {
                        return gv + "." + b[parseInt(c, 16)] + "+"
                    });
                    s = "";
                }
            }
            if (s) r += """ + s + ""+";
    
            r =
                gv + "=~[];" +
                gv + "={___:++" + gv + ",$$$$:(![]+"")[" + gv + "],__$:++" + gv + ",$_$_:(![]+"")[" + gv + "],_$_:++" +
                gv + ",$_$$:({}+"")[" + gv + "],$$_$:(" + gv + "[" + gv + "]+"")[" + gv + "],_$$:++" + gv + ",$$$_:(!""+"")[" +
                gv + "],$__:++" + gv + ",$_$:++" + gv + ",$$__:({}+"")[" + gv + "],$$_:++" + gv + ",$$$:++" + gv + ",$___:++" + gv + ",$__$:++" + gv + "};" +
                gv + ".$_=" +
                "(" + gv + ".$_=" + gv + "+"")[" + gv + ".$_$]+" +
                "(" + gv + "._$=" + gv + ".$_[" + gv + ".__$])+" +
                "(" + gv + ".$$=(" + gv + ".$+"")[" + gv + ".__$])+" +
                "((!" + gv + ")+"")[" + gv + "._$$]+" +
                "(" + gv + ".__=" + gv + ".$_[" + gv + ".$$_])+" +
                "(" + gv + ".$=(!""+"")[" + gv + ".__$])+" +
                "(" + gv + "._=(!""+"")[" + gv + "._$_])+" +
                gv + ".$_[" + gv + ".$_$]+" +
                gv + ".__+" +
                gv + "._$+" +
                gv + ".$;" +
                gv + ".$$=" +
                gv + ".$+" +
                "(!""+"")[" + gv + "._$$]+" +
                gv + ".__+" +
                gv + "._+" +
                gv + ".$+" +
                gv + ".$$;" +
                gv + ".$=(" + gv + ".___)[" + gv + ".$_][" + gv + ".$_];" +
                gv + ".$(" + gv + ".$(" + gv + ".$$+"\""+" + r + ""\"")())();";
    
            return r;
        }
    
    
    </script>
    </body>
    </html>

    加密后的内容:

     

  • 相关阅读:
    人人数据挖掘实习生面经
    关于贝叶斯分类中的二项独立模型和多项式模型
    关于序列的面试题1 判断整数序列是否是二叉排序树的后续遍历
    机器学习经典算法之最小二乘法
    协同过滤算法之—slope one算法
    关于序列的面试题2最大连续子序列和以及积
    控制DOUBLE,DECIMAL小数点的位数
    Invoke的用法
    windowForm学习资料总结
    .NET开发编程规范
  • 原文地址:https://www.cnblogs.com/yang-2018/p/13695237.html
Copyright © 2020-2023  润新知