JS字符串“隐形”加密技术,完整源码

相关标签: # html# 技术# 工具
技术原理请见文章:
https://blog.51cto.com/jsjiami/5995444
源码:
<html>
<h2>字符串隐身术h2>
<textarea id="code" style="font-size:9px; height:500px; width: 600px;">
console.log = function(){
for(i=0; i<arguments.length;i++){
document.getElementById("log").innerHTML += arguments[i];
}
document.getElementById("log").innerHTML += "
";
}
function text_2_binary(text){
return text.split('').map(function(char){ return char.charCodeAt(0).toString(2)}).join(' ');
}
function binary_2_hidden_text(binary){
return binary.split('').map(function (binary_num){
var num = parseInt(binary_num, 10);
if (num === 1) {
return '\u200b';
} else if(num===0) {
return '\u200c';
}
return '\u200d';
}).join('\ufeff')
}
var text = "jshaman是专业且强大的JS代码混淆加密工具";
var binary_text = text_2_binary(text);
var hidden_text = binary_2_hidden_text(binary_text);
console.log("原始字符串:",text);
console.log("二进制:",binary_text);
console.log("隐藏字符:
",hidden_text,"隐藏字符长度:",hidden_text.length);
function hidden_text_2_binary(string){
return string.split('\ufeff').map(function(char){
if (char === '\u200b') {
return '1';
} else if(char === '\u200c') {
return '0';
}
return ' ';
}).join('')
}
function binary_2_Text(binaryStr){
var text = ""
binaryStr.split(' ').map(function(num){
text += String.fromCharCode(parseInt(num, 2));
}).join('');
return text.toString();
}
console.log("隐形字符转二进制:",hidden_text_2_binary(hidden_text));
console.log("二进制转原始字符:",binary_2_Text(hidden_text_2_binary(hidden_text)));
textarea>
<br>
<button onclick="eval(document.getElementById('code').value);">执行JS代码button>
<br>
<div id="log">div>
html>
文章来源: https://blog.51cto.com/jsjiami/6001717
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报