Last active
October 16, 2024 19:56
-
-
Save aarongeorge/9c6495a49304b85d6008104e84ad824c to your computer and use it in GitHub Desktop.
A code generator that takes Javascript and compiles it to ASCII Control Characters that are not visible, based on Martin Kleppe's "Invisible Code" talk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Invisible Code Generator | |
* | |
* Description: | |
* A code generator that takes Javascript and compiles it to | |
* ASCII Control Characters that are not visible | |
* | |
* Usage: | |
* Copy and paste the code into your browsers console | |
* Then paste the code you wish to convert to "Invisible Code" | |
* Your code will then be copied to your clipboard | |
* | |
* Credits: Martin Kleppe aka @aemkei | |
* | |
* Author: Aaron George | |
* Github: github.com/aarongeorge | |
*/ | |
const textToHex = t => t.split('').map(c => (`0${c.charCodeAt(0).toString(16)}`).slice(-2)).join(' ') | |
const hexToControlCharacter = h => h.split(' ').map(c => c.replace(/(.)(.)/, '%1$1%1$2')).join('') | |
const codeToHide = window.prompt('Enter your code') | |
const hex = textToHex(codeToHide) | |
const cc = unescape(hexToControlCharacter(hex)) | |
// Copy text to clipboard | |
copy(`eval(eval('"'+escape("${cc}").replace(/..(.)..(.)/g,'\\\\x$1$2')+'"'))`) | |
// Alert that the text is there | |
window.alert('Code has been copied to your clipboard') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment