我正在尝试使用javascript抓取我网页上的所有元素。一旦我这样做,我想隐藏元素中的消息,可能是LSB。现在我只是试图隐藏'h',这将是8位,我认为这需要8个elementID。
我的计划是获取所有ID。使用charCodeAt获取'h'的值,然后使用文本大小或宽度字段上的按位运算隐藏前8个elementID中的h位。
我知道这是一种隐藏信息的可怕方式,但我真的想把它想象成学习目的。关于如何做到这一点或方向的任何想法都会很棒。
这是我到目前为止所拥有的......
$(function() {
//on button click
// 1. grab LSB all of elements to be changed
// 2. change all elements
// str.charCodeAt(0);
//var arrayMsg = hideMsg.split("");
/*
// 1. maybe grab all elements on the page
// 2. make a special class with width and text
// 3. inject all element IDs with this class
// 4. flip this classes width/text size with LSB of message to hide
var allElements = document.getElementsByTagName("*");
var allIds = [];
for (var i = 0, n = allElements.length; i < n; ++i) {
var el = allElements[i];
if (el.id) { allIds.push(el.id); }
}
*/
var hideMsg = "f";
var n = hideMsg.length;
var i;
var j;
var holder;
var hideHolder;
// on button click - hide msg
$('#btnHide').on('click', function() {
for(i = 0; i < n; i++) {
//set var holder to first value of the message to hide
holder = hideMsg.charCodeAt(i);
for(j = 7; -1 < j; j--) {
//set hideHolder to holders value
hideHolder = holder;
//mask hideHolder to grab the first bit to hide
hideHolder = hideHolder & (1<<j);
//grab the first element ID
if(holder === 0) {
// embed the bit
// bitwise &=
} else {
//embed the bit
// bitwise ^=
}
}
}
});
});