aemkei / jsfuck

Write any JavaScript with 6 Characters: []()!+
jsfuck.com
Do What The F*ck You Want To Public License
8.07k stars 671 forks source link

Update README.md #107

Open kamil-kielczewski opened 3 years ago

kamil-kielczewski commented 3 years ago

escape/unescape for get all characters without using deprecated methods

hazzik commented 3 years ago

Using escape is strictly speaking not a discovery. The italics (and other "deprecated" methods) are used to get a shorter version. Current version is at least 100 characters shorter than the version in the SO answer. And whopping 2100 characters shorter than formula at "step5". (The shortest version would be with atob/btoa, but it does not work everywhere).

hazzik commented 3 years ago

Also, all the current formulas were found using the automatic methods.

kamil-kielczewski commented 3 years ago

@hazzik ok - but I think such information should be included in documentation (because lack of that I was deluded and loose a lot of time on try to solve this problem with "C" - and finnaly I ask on StackOverflow). It is not trivial (to get that 'critical' letter "C" without using deprecated methods). And in case when deprecated method stops work, this is also some kind of semi-protection (because escape is not strictly deprecated). We can also add information that deprecated method was used because of size-optimalization.

Can you give som link which shows that this technique was discovered earlier? Then we change links to that source. (we can also change text in more proper way - if you have some alternative proposition)

kamil-kielczewski commented 3 years ago

optimization: @hazzik I see that you like optimizastions some time a go I give proposition #70 (2 years ago) to introduce simple "compression" (actually conversion) - and finnaly I do it myself yesterday - look on this little project - may be it will be interesting for you (it gives ~10x smaller code and this proportion increase when input code size growths). For me in that project it was important to use non-deprecated methods in decompression code (I not introduce this solution there yet) to get more "durable" version

aemkei commented 3 years ago

I like the idea of encoding the characters into numbers in a bootstrap to save space.

Have you thought about using octal sequences? This would save some some space per characters:

EG:

eval(eval("'91419154914591629164950961951'".replace(/9/g, "\\")))

The bootstrap code is ~25k but maybe we can save some bytes by replacing the quotes or backspace.

kamil-kielczewski commented 3 years ago

@aemkei Interesting idea - In free time I will check this and compare with base4. However currently I don't understand how abort(1) is coded inside eval('\141\154\145\162\164\50\61\51') :P

Update: Ok now I get: '\141\154\145\162\164\50\61\51' in chrome console gives "alert(1)" - very clever, may be it is the way to get even better "compression" ratio

hazzik commented 3 years ago

The bootstrap code is ~25k

I managed to reduce it to 5k, see my PR

kamil-kielczewski commented 3 years ago

@aemkei I analyse and test you proposition details here (base4 is better) and I propose more promising modification which (in details) I analyse in near future