Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save JavaScript-Packer/77816cc3d0df67d7c1b2 to your computer and use it in GitHub Desktop.

Select an option

Save JavaScript-Packer/77816cc3d0df67d7c1b2 to your computer and use it in GitHub Desktop.
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));
return a[R](/\0/g, "");}
document["\x77r\x69\x74e"]('<h4>Nothingness (Just Spaces) Encoder By <a href="http://www.whak.ca">WHAK.com</a><\/h4><textarea id="x" rows="25" cols="80" onmouseover="this.select()"><\/textarea><br><button onclick="$=x.value;x.value=whak($)">Encode<\/button><button onclick="$=x.value;x.value=unwhak($)">Decode<\/button>');
//minified to less than 1,024 bytes (1KB), weighing in at 998 bytes
/*
function whak(P){var D,e,r,t="";for(D=0;D<P.length;D++)e=P.charCodeAt(D).toString(10),
r=e[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," "),t+=r+"​";
return t}function unwhak(P,D,e,r,t){for(t="",P=P.split("​"),D=0;D<P.length;D++)e=P[D],
r=e[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"),t+=String.fromCharCode(parseInt(r,10));return t[R](/\0/g,"")}
document.write('<h4>Nothingness (Just Spaces) Encoder By <a href="http://www.whak.ca">WHAK.com</a></h4><textarea id="x" rows="25" cols="80" onmouseover="this.select()"></textarea><br><button onclick="$=x.value;x.value=whak($)">Encode</button><button onclick="$=x.value;x.value=unwhak($)">Decode</button>');
*/
@JavaScript-Packer

Copy link
Copy Markdown
Author

HTML version:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>Space Encode/Decode</title>
</head>
<body>
<h4>Nothingness (Just Spaces) Encoder By <a href='http://www.whak.ca'>WHAK.com</a></h4>
<textarea id="x" rows="25" cols="80" onmouseover="this.select()"></textarea><br>
<button onclick="$=x.value;x.value=whak($)">Encode</button> 
<button onclick="$=x.value;x.value=unwhak($)">Decode</button>
<script>
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));
  return a[R](/\0/g, "");}
  </script>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment