2

I am learning javascript by studying many file .js but I can't understand anything. Many of them start with:

(function(){var aa=encodeURIComponent,f=window,ba=setTimeout,n=Math,ea=RegExp;function fa(a,b){return a.name=b}function Pc(a,b){return a.href=b}...

I think this is one way to encrypt the code to protect. Am I right? If it's true, how can I do it? If I want to decrypt it, plz show me how to do. Thanks. p/s: I'm a newbie

6
  • 2
    these are minified javascript. you can google minified js for more information Commented Feb 25, 2014 at 9:55
  • The goal is just to have smaller files (and some minifiers can also make them marginally faster to execute). Commented Feb 25, 2014 at 9:56
  • 1
    There are few things that can obscure javascript, one is minification and other is obfuscation. In first case (minifaction) you can always use some kind of javascript formatter to get cleaner version of the JS (like jsbeautifier.org ), but with obfuscation it's harder to understand the code as it uses tricks to make the code unreadable (it still can be changed / modified and even extracted). Commented Feb 25, 2014 at 9:58
  • 2
    Paste the code in jsbeautifier.org - it will be more readable. You still have horrible short variable names and other optimizations in it that will make it hard to read though. Commented Feb 25, 2014 at 9:58
  • Paste it here: jsbeautifier.org Commented Feb 25, 2014 at 9:58

3 Answers 3

4

You cannot really encrypt javascript. You can obfuscate which makes it harder to read and minify (which is arguebly also harder to read, but more importantly has a smaller footprint)

MINIFY

http://jscompress.com/ is one such minifier.

If you wish to obfuscate your code (thus making it harder to read, but not making it smaller (in fact usually you end up with more bytes), you could look at this:

OBFUSCATE

http://javascriptobfuscator.com/

BEAUTIFY

Like the comments here said, to 'decrypt' said piece of code, you could go to http://jsbeautifier.org/. Although when it's obfuscated it won't do you much good.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Do you know how to make it become like (function(){var aa=encodeURIComponent,f=window,ba=setTimeout,n=Math,ea=RegExp;function fa(a,b){return a.name=b}function Pc(a,b){return a.href=b}
1

The code you present:

(function(){var aa=encodeURIComponent,f=window,ba=setTimeout,n=Math,ea=RegExp;function fa(a,b){return a.name=b}function Pc(a,b){return a.href=b}...

Is JavaScript minification. You can use tools such as jscompress for minification

Instead of encryption, obfuscation is used for JavaScript which is used to protect your code making it harder to read and understand. There are tools for obfuscation aswell. Check out javascriptobfuscator

1 Comment

Thank you. I find myself a fool when I read a code of js which is full of functions containing a, bc, Ig, c>0, a-1... :( like {var gc=function(a,b){var c=n.min(R(a,dc),100);if(!(La(P(a,Q))%100>=c)&&(c={},Ec(c)|..}
0

It Means the file.js a minified version Compresd Javascript file

You will have to work hard to convert minified version to normal js files, but we have some tools see below..

http://jsbeautifier.org/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.