Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / run-length-encode.js
Created May 10, 2015 15:35
Run Length Encode & Decoder JavaScript functions - Live demo on http://www.whak.ca/demo/run-length-encode.htm
// run length encoder/decoder, not useful when sequence has numbers already in it
function encode_rle(r) {
for (var o, i, n = 0, t = r.length, e = ""; t > n; ++n) void 0 !== o ? r[n] === o ? i++ :(e += i + o,
o = r[n], i = 1) :(o = r[n], i = 1);
return e + (i + o);
}
function decode_rle(r) {
var t, n = /^\d+/.exec(r);
return null === n ? "" :(n = n[0], t = r[n.length], Array(+n + 1).join(t) + decode_rle(r.substr((n + t).length)));
@JavaScript-Packer
JavaScript-Packer / encode-decode-binary.js
Last active August 29, 2015 14:20
Binary encoder/decoder functions that let you choose a combiner/joiner for each binary. Live demo on http://www.whak.ca/demo/encode-decode-binary.htm
function ascii2binary(e, joiner) {
return Array.prototype.map.call(e, function(e) {
var t = e.charCodeAt(0).toString(2);
return "00000000".substr(t.length) + t;
}).join(joiner);
}
function binary2ascii(e, joiner) {
if (!joiner)joiner=" "; //added so you can leave joiner blank e.g. joiner="";
return e.replace(RegExp(joiner + "*[01]{8}" + joiner + "*", "g"), function(e) {
return String.fromCharCode(parseInt(e, 2));
@JavaScript-Packer
JavaScript-Packer / Twitter-Text-Compressor.js
Last active August 29, 2015 14:20
Another Twitter string compressor. In base 36 I found over 18,000 possible lowercase combinations of letters only. Live demo on http://www.whak.ca/disfunction.htm
//Another Twitter string compressor. In base 36 I found over 18,000 posible combinations of letters only.
//My name is Dave, there is character 㜊 (code 㜊) that looks like "ave"
//javascript:alert(parseInt('ave', 36)), so I can literally encode my name to 2 characters instead of 5.
document['wr'+'ite'](unescape("%3Ctextarea%20id=whak%20rows=%226%22%20cols=%2277%22%20onmouseover=%22this.select()%22%3EDave%20suggests%20that%20you%20visit%20www.ScriptCompress.com%20for%20many%20neat%20JavaScript%20programming%20tools!%3C%2Ftextarea%3E%3Cinput%20type=text%20id=%22szwhak%22%20size=%225%22%3E%3Cbr%3E%3Ctextarea%20id=%22pack%22%20rows=%226%22%20cols=%2277%22%20onmouseover=%22this.select()%22%3E%3C%2Ftextarea%3E%3Cinput%20type=text%20id=%22szpack%22%20size=%225%22%3E%3Cbr%3E%3Cinput%20type=%22button%22%20id=%22encoder%22%20onclick=%22encode(whak.value)%22%20value=%22Twit%20Compress%22%3E%3Cinput%20type=%22button%22%20id=%22decoder%22%20onclick=%22decode()%22%20value=%22Twit%20Decompress%22%3E"));
function disf
@JavaScript-Packer
JavaScript-Packer / weird-base64-trick.txt
Last active October 16, 2025 07:45
Being Silly, Decode words by Actually Encoding with Base64, made by a modded Base64 script, demo on http://www.whak.ca/demo/base64-glitch.htm
In JavaScript, this will make an alert:
eval(unescape(btoa("jW«·ý¼ÿnՊȭÿm0Ãöy'+Š›B¢jkzË?Ùç(›ý»ÿoÝ¿öýŸ").replace(/\57/g,"\45")));
$DJ
If you encode the above with Base64 it will give you the word JERK
,åD
If you encode the above with Base64 it will give you the word LOVE
@JavaScript-Packer
JavaScript-Packer / javascript-packer-codepoints.js
Created May 4, 2015 11:53
A JavaScript Packer that encodes to code points of characters. Live demo on http://www.whak.ca/demo/codepoints-packer.htm
var $='WHAK',w=document,h='getElementById',a="javascript",k="value",o="packer";
w.writeln('<h4><a href="http://www.'+$+'.ca">JavaScript Source Code To Code Points Packer</a></h4>\
<textarea id=javascript rows=6 cols=77 onmouseover=this.select()>alert("www.'+$+'.com");<\/textarea>\
<br><textarea id=packer rows=6 cols=77 onmouseover=this.select()><\/textarea><br>\
<input value="Pack" type=button onclick="w[h](o)[k]=Pack_JS_2_Codepoints(w[h](a)[k]);"> \
<input value="Test" type=button onclick="eval(w[h](o)[k]);">');
function Pack_JS_2_Codepoints(W,H,A,K){K=W.replace(/./g,function(H){
return","+H.charCodeAt(0)});A="eval(String.fromCharCode("+K.replace(",","")+"));";return A}
w[h](o)[k]=Pack_JS_2_Codepoints(w[h](a)[k]);
//Try it on http://www.whak.ca/demo/codepoints-javascript-packer.htm
@JavaScript-Packer
JavaScript-Packer / replace-variable.js
Created May 4, 2015 00:54
Function to replace global using regex/regexp. Live demo on http://jsfiddle.net/v6f4nbhL/
function replacer(W, H, A, K) {
K = W.replace(new RegExp(H, "g"), A);
return K;
}
var str = "WHom";
var find = "Ho";
var r3plac3 = "HAK\u002eco";
alert(replacer(str, find, r3plac3));
@JavaScript-Packer
JavaScript-Packer / 8bit-binary-combinations.js
Created May 3, 2015 15:22
Get all possible combinations and permutations for 8-bit binary. Live demo on http://jsfiddle.net/eur7o7eL/
function possible(e, n, t, r, W) {
if (0 === e.length) {
return [];
}
if (1 === e.length) {
return e[0];
}
n = [], t = possible(e.slice(1));
for (r in t) {
for (W = 0; W < e[0].length; W++) {
@JavaScript-Packer
JavaScript-Packer / hidden-eval.js
Last active August 29, 2015 14:20
Command Runner Function - Highly obfuscated eval because some sites do not allow it (usually confuse it with PHP's evil eval)... Live demo on http://jsfiddle.net/rb46a1rr/1/
/* 348 bytes command runner AKA hidden eval, I modfied code from aemkei */
function command2(run) {
ウ = "", ア = !ウ + ウ, ネ = !ア + ウ, ホ = ウ + {}, ヌ = ア[ウ++], セ = ア[ミ = ウ], ハ = ++ミ + ウ,
ヘ = ホ[ミ + ハ], ア[ヘ += ホ[ウ] + (ホ.ホ + ホ)[ウ] + ネ[ハ] + ヌ + セ + ア[ミ] + ヘ + ヌ + ホ[ウ] +
セ][ヘ](ア[ハ] + "v" + ネ[ウ] + ネ[ミ] + "(" + run + ")")();
}
//command2("alert('WHAK.com'),alert(9)"); //semicolons will break it
// minified version to 256 bytes
/*
@JavaScript-Packer
JavaScript-Packer / decombine.js
Created May 3, 2015 11:06
Seperate combining characters, break out to individual characters. Demo on http://jsfiddle.net/j91k1x46/
//uncombine combined combiners
function Δ(n, t, r, o) {
for (o = [], t = 0, r = n.length; r > t; ++t) {
o.push(n.charAt(t));
}
return o.join(" ");
}
alert(Δ("S̨̥̫͎̭ͯ̿̔̀ͅ"));
@JavaScript-Packer
JavaScript-Packer / blank-spaces-encoding.js
Last active August 29, 2015 14:20
Encode text to spaces (zerowidth, etc), it will appear invisible until you decode it. Complete web app in JavaScript. Live demo on http://www.whak.ca/invisible-encoder.htm
function whak(e) {
var r, n, t, a = "";
for (r = 0; r < e.length; r++) n = e.charCodeAt(r).toString(10), t = n[R = "replace"](/0/g, " ")[R](/1/g, "‌")[R](/2/g, "‍")[R](/3/g, "‎")[R](/4/g, "‏")[R](/5/g, " ")[R](/6/g, " ")[R](/7/g, " ")[R](/8/g, " ")[R](/9/g, " "),
a += t + "​";
return a;}
function unwhak(o, r, n, t, a) {
a = "";
o = o.split("​");
for (r = 0; r < o.length; r++) n = o[r], t = n[R = "replace"](/ /g, "0")[R](/‌/g, "1")[R](/‍/g, "2")[R](/‎/g, "3")[R](/‏/g, "4")[R](/ /g, "5")[R](/ /g, "6")[R](/ /g, "7")[R](/ /g, "8")[R](/ /g, "9"),
a += String.fromCharCode(parseInt(t, 10));