unicode编码--charCodeAt&fromCharCode

   # 编码
    function unicodey(json) {
        var json = json;
        var str = JSON.stringify(json);
        str = str.replace(/\ +/g, "");
        str = str.replace(/[\r\n]/g, "");
        var arr = str.split('');
        for (var i = 0; i < arr.length; i++) {
            arr[i] = arr[i].charCodeAt() + 'з';
        }
        RES = arr.join('');
        console.log(RES)
    }
    # 解码
    var code = String.fromCharCode.apply(null, RES.split(/з/ig));


    # ex:
    ## 服务端和客户端之间传输json数据
    var json = {a:'qq',b:'wx'};

    ## 加密js代码
    var str = `  console.log( 'good job you have down') `;

你可能感兴趣的:(unicode编码--charCodeAt&fromCharCode)