Skip to content

Instantly share code, notes, and snippets.

@cflems
cflems / obfuscator.js
Last active December 12, 2022 10:01
Obfuscate JavaScript code into having zero readable characters; I want to improve this not to use eval at all but I'll have to write a JS tokenizer for that.
const zero = '+[]'; // 1
const one = '+!![]'; // 1
const two = '('+ one + one +')'; // 2
const three = '('+ one + one + one +')'; // 3
const four = '('+ one + one + '<<' + one +')'; // 3
const five = '('+ four + one +')'; // 4
const six = '('+ one + one + one + '<<' + one +')'; // 4
const seven = '('+ six + one +')';
const eight = '('+ one + one + '<<' + one + one +')'; // 4
const int_lits = {0: zero, 1: one, 2: two, 3: three, 4: four, 5: five, 6: six, 7: seven, 8: eight};