User:Jan jelo/JSFuck code generator
Jump to navigation
Jump to search
This is a JSFuck code generator in python by User:Jan jelo. (not the best translation)
false='(![])' true=f'!{false}' _0=f'(+[])' _1=f'(+{true})' _2=f'({_1}+{_1})' _3=f'({_1}+{_2})' _4=f'({_2}+{_2})' _5=f'({_2}+{_3})' _6=f'({_3}+{_3})' _7=f'({_3}+{_4})' _8=f'({_4}+{_4})' _9=f'({_4}+{_5})' nums=[_0,_1,_2,_3,_4,_5,_6,_7,_8,_9] def num(n): x='+'.join([f'[{nums[int(x)]}]'for x in str(n)]) return f'(+({x}))' undefined=f'([][{_0}])' a=f'(({false}+[])[{_1}])' d=f'(({undefined}+[])[{_2}])' e=f'(({true}+[])[{_3}])' f=f'(({false}+[])[{_0}])' i=f'(({undefined}+[])[{_5}])' l=f'(({false}+[])[{_2}])' n=f'(({undefined}+[])[{_1}])' r=f'(({true}+[])[{_1}])' s=f'(({false}+[])[{_3}])' t=f'(({true}+[])[{_0}])' u=f'(({true}+[])[{_2}])' c=f'((([][{f}+{l}+{a}+{t}])+[])[{_3}])' o=f'((([][{f}+{l}+{a}+{t}])+[])[{_6}])' constructor=f'({c}+{o}+{n}+{s}+{t}+{r}+{u}+{c}+{t}+{o}+{r})' Function=f'([][{f}+{l}+{a}+{t}][{constructor}])' Number=f'({_0}[{constructor}])' m=f'(({Number}+[])[{num(11)}])' _space=f'(({Number}+[])[{_8}])' name=f'({n}+{a}+{m}+{e})' String=f'(([]+[])[{constructor}])' toString=f'{t}+{o}+({String}[{name}])' v=f'(({Number}+[])[{num(25)}])' _eval=f'({Function}({r}+{e}+{t}+{u}+{r}+{n}+{_space}+{e}+{v}+{a}+{l})())' p=f'({num(25)}[{toString}]({num(36)}))' h=f'({num(17)}[{toString}]({num(36)}))' C=f'({Function}({r}+{e}+{t}+{u}+{r}+{n}+{_space}+{e}+{s}+{c}+{a}+{p}+{e})()(([]+[])[{i}+{t}+{a}+{l}+{i}+{c}+{s}]())[{_2}])' _chr=f'({String}[{f}+{r}+{o}+{m}+{C}+{h}+{a}+{r}+{C}+{o}+{d}+{e}])' def chrOf(n): return f'({_chr}{num(ord(n))})' def find(x): if x.isdigit():return f'({nums[int(x)]}+[])' return { 'a':a,'c':c,'d':d,'f':f,'h':h,'i':i,'l':l,'m':m,'n':n,'o':o,'p':p,'r':r,'t':t,'u':u,'v':v, }.get(x,chrOf(x)) def convert(s):return '('+'+'.join(map(find,s))+')' def gen(code):return f'{_eval}{convert(code)}' program=r'console.log("Hello,world!")' print(gen(program))