const param1 = '123456' const securityEncode = function(input1, input2, input3) { var dictionary = input3; var output = ""; var len, len1, len2, lenDict; var cl = 0xBB, cr = 0xBB; len1 = input1.length; len2 = input2.length; lenDict = dictionary.length; len = len1 > len2 ? len1 : len2; for (var index = 0; index < len; index++) { cl = 0xBB; cr = 0xBB; if (index >= len1) { cr = input2.charCodeAt(index); } else if (index >= len2) { cl = input1.charCodeAt(index); } else { cl = input1.charCodeAt(index); cr = input2.charCodeAt(index); } output += dictionary.charAt((cl ^ cr)%lenDict); } return output; }; const auth = async (pwd)=>{ let res1 = await fetch('http://192.168.0.1/common/Content.htm') let res2 = await res1.text() let authInfo = res2.split('\r\n') let url = "http://192.168.0.1/?code=7&asyn=0"; url += ("&id=" + encodeURIComponent(securityEncode(authInfo[3], pwd, authInfo[4]))); fetch(url) return pwd; } const param2 = securityEncode(param1,"RDpbLfCPsJZ7fiv","yLwVl0zKqws7LgKPRQ84Mdt708T1qQ3Ha7xv3H7NyU84p21BriUWBU43odz3iP4rBL3cD02KZciX"+ "TysVXiV8ngg6vL48rPJyAUw0HurW20xqxv9aYb4M9wK1Ae0wlro510qXeU07kV57fQMc8L6aLgML"+ "wygtc0F10a0Dg70TOoouyFhdysuRMO51yY5ZlOZZLEal1h0t9YQW0Ko7oBwmCAHoic4HYbUyVeU3"+ "sfQ1xtXcPcf1aT303wAQhv66qzW"); auth(param2).then(param3 =>{ console.log(param3) })