Billy Hoffman - JSConf 2010
Billy Hoffman - JSConf 2010
Dehydrating Code
* Converts any string into whitespace
* 7 bit per character: 1 = space, 0 = tab
* \n means we are done
* 'a' = 1100001
* dehydrate('a') = space, space, tab, tab, tab, ...
function dehydrate(s) {
var r = new Array();
for(var i=0; iif (s.charCodeAt(i) & (Math.pow(2, j))) {
r.push(' ');
} else {
r.push('\t');
}
}
r.push('\n');
return r.join('');
}
function hydrate (s) {
var r = []; var curr = 0;
while(s.charAt(curr) != '\n') {
var tmp = 0;
for (var i=6; i>=0; i--) {
if (s.charAt(curr) == '') tmp = tmp | (Math.pow(2, i));
curr++;
}
r.push(String.fromCharCode(tmp));
}
return r.join('');
}
//startevil
//endevil
var html = document.body.innerHTML;
var start = html.indexOf("//start" + "tevil");
var end = html.indexOf("//end" + "evil");
eval(dydrate(html.substring(start+12, end)));
沒有留言:
張貼留言