Skip to content

Instantly share code, notes, and snippets.

@artsobolev
Created November 28, 2014 18:53
Show Gist options
  • Select an option

  • Save artsobolev/5efee489c44720d1679a to your computer and use it in GitHub Desktop.

Select an option

Save artsobolev/5efee489c44720d1679a to your computer and use it in GitHub Desktop.

Revisions

  1. [email protected] created this gist Nov 28, 2014.
    31 changes: 31 additions & 0 deletions Stego.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    var revealJS = function(s) {
    var hexAlphabet = Array.apply(null, {
    length: 10
    }).map(Number.call, Number).concat('abcdef'.split(''));
    var codes = [8289, 8204, 8205, 8206, 8207, 8234, 8235, 8236, 8237, 8238, 8298, 8299, 8300, 8301, 8302, 8303];

    return s.match(/(.{4})/g).map(function(b) {
    return b.split('').map(function(i) {
    return hexAlphabet[codes.indexOf(i.charCodeAt())]
    })
    }).map(function(c) {
    return String.fromCharCode(0 + "x" + c.join(''))
    }).join('')
    }

    var invisibleJS = function(s) {
    return s.replace(/./g, function(b) {
    var code = '0000' + b.charCodeAt().toString(16);
    code = code.substring(code.length - 4);
    return String.fromCharCode.apply(String, code.split('').map(function(a) {
    hexAlphabet = Array.apply(null, {
    length: 10
    }).map(Number.call, Number).map(function(n) {
    return n.toString();
    }).concat('abcdef'.split(''));
    codes = [8289, 8204, 8205, 8206, 8207, 8234, 8235, 8236, 8237, 8238, 8298, 8299, 8300, 8301, 8302, 8303];
    var idx = hexAlphabet.indexOf(a);
    return codes[idx]
    }))
    })
    }