我通过研究许多文件.js来学习javascript,但我什么都听不懂。 其中许多开头是:
(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}...我认为这是加密代码以保护的一种方法。 我对吗? 如果是真的,我该怎么办? 如果我想解密它,请告诉我该怎么做。 谢谢。 p / s:我是新手
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
最满意答案
你无法真正加密javascript。 你可以混淆,这使得它更难以阅读和缩小(有争议的是更难阅读,但更重要的是占用空间更小)
缩小
http://jscompress.com/是一个这样的缩小器。
如果你想混淆你的代码(从而使它更难阅读,但不会让它变小(事实上通常你会得到更多的字节),你可以看看这个:
混淆
http://javascriptobfuscator.com/
美化
就像这里的评论所说的那样,为了'解密'所说的代码,你可以去http://jsbeautifier.org/ 。 虽然当它被混淆时,它对你没有多大帮助。
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.
更多推荐
发布评论