在Node.JS中調(diào)用JShaman接口,實(shí)現(xiàn)JS代碼加密。
使用axIOS庫(kù)實(shí)現(xiàn)https的post請(qǐng)求,代碼如下:
const axios = require("axios");const jshamanConfig = { //源碼 "js_code": 'function get_copyright(){ var domain = "中文"; var from_year = 2017; var copyright = "(c)" + from_year + "-" + (new Date).getFullYear() + "," + domain; return copyright;}console.log(get_copyright());', //vip碼 "vip_code": "free",};axios.post("https://www.jshaman.com:4430/submit_js_code", jshamanConfig).then(function (res) { if (res.status == 200) { if (res.data && res.data.status == 0) { console.log("----請(qǐng)求成功----"); console.log(res.data.content) } else { console.error(res.data.message); } } else { console.error(res.status); } }).catch(function (error) { console.error(error); });
運(yùn)行后,得到了加密的JS代碼,如下圖:
上面,使用的是JShaman的免費(fèi)接口,如同在官網(wǎng)使用免費(fèi)加密效果一樣:
如要配置參數(shù),則需寫(xiě)入自己在JShaman的VIP碼,帶參數(shù)可啟用更多保護(hù)選項(xiàng),加密效果會(huì)更好。
代碼如下:
const axios = require("axios");const jshamanConfig = {//源碼"js_code": 'function get_copyright(){ var domain = "中文"; var from_year = 2017; var copyright = "(c)" + from_year + "-" + (new Date).getFullYear() + "," + domain; return copyright;}console.log(get_copyright());',"config":{// 壓縮"compact": true,//平展控制流"controlFlowFlattening": true,//僵尸代碼"deadCodeInjection": true,//字符串陣列化"stringArray": true,//字符串加密"stringArrayEncoding": true,//禁用命令行輸出"disableConsoleOutput": false,//反瀏覽器調(diào)試"debugProtection": true,//時(shí)間限定"time_range": false,"time_start": "","time_end": "",// 域名鎖定"domainLock": [],// 保留字"reservedNames": []},//JShaman vip碼"vip_code": "vip碼",};axios.post("https://www.jshaman.com:4430/submit_js_code", jshamanConfig).then(function (res) {if (res.status == 200) {if (res.data && res.data.status == 0) {console.log("----請(qǐng)求成功----");console.log(res.data.content)} else {console.error(res.data.message);}} else {console.error(res.status);}}).catch(function (error) {console.error(error);});
運(yùn)行效果: