如何阻止javascript代码 [英] How to obsfucate javascript code

查看:77
本文介绍了如何阻止javascript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的网页隐藏我的javascript代码。

我看到当我们右键点击任何网页并查看源代码时我们可以查看java脚本代码。无论是嵌入还是外部javascript文件。





谢谢。

解决方案

< blockquote>这是带有混淆工具的CodeProject文章: EasyPack - 按钮批量JavaScript错误检查,压缩和混淆工具 [ ^ ]。



看看过去问题的答案:如何在asp.net的aspx页面中隐藏css文件和javascript文件 [ ^ ]。



在Yusuf的回答中你会找到一些混淆器。但是也请在本页以及整个讨论中阅读我的答案并问自己:为什么?



参见这个答案和讨论:如何使用记事本保护javascript中的源代码 [ ^ ]。



-SA


你不能。如果浏览器无法看到它,则无法运行它。如果能看到它,用户就可以看到它。这对我来说显而易见。你可以阻止它,但你不能隐藏它。这意味着,您可以使用工具使其更难阅读。


您可以做的最好的事情就是混淆JavaScript代码,使其无法读取。它仍然可以被有动力和充足的业余时间的人解码,但是,对于在客户端上运行的代码,包括二进制可执行文件,情况总是如此。请注意,混淆的JavaScript是,或者至少需要更长的时间才能加载。



这里有一些链接解决方案: http://stackoverflow.com/questions/194397/how-can-i-obfuscateprotect- javascript [ ^ ]。



让我添加一些以上链接中未包含的内容:如果您使用的是Visual Studio,那么您可能拥有Dotfuscator,这是一个很棒的工具混淆asp.net代码和常规JavaScript。



http://www.jsobfuscate .com [ ^ ]是几个快速混淆器之一浏览器(只需复制并粘贴JavaScript并按下按钮)。如果生成的输出的大小不是问题,这是一个很好的工具。



最后我最喜欢的一个: http://jscrew.it [ ^ ]对任何JavaScript进行编码只使用6个不同的字符(无需按下按钮),有一个可以在本地运行的Node.js模块,它可以编码jQuery大小的文件(不,严重 [ ^ ]。



也有商业解决方案,但我想如果你寻找JavaScript混淆,谷歌很容易找到它们,尽管我不建议花钱购买这些工具。

这应该足以让你入门: - )


I want to hide my javascript code from my web page.
I see when we right click on any webpage and view source we are able to view the java script code. Whether it is embeded or external javascript file.


Thanks.

解决方案

This is the CodeProject article with obfuscation tool: EasyPack - A Pushbutton Batch JavaScript Error Checking, Compression, and Obfuscation Tool[^].

Look at this answer to past question: how can hide css file and javascript file from aspx page in asp.net[^].

In this answer by Yusuf you will find some obfuscator. But also read my answer on this page as well as the whole discussion and ask yourself: why?

See also this answer and discussion: How to protect source code in javascript using notepad[^].

—SA


You can't. If the browser can't see it, it can't run it. If it can see it, users can see it. That seems obvious to me. You can obsfucate it, but you can't hide it. That means, you can use tools to make it harder to read.


The best you can do is obfuscating your JavaScript code to make it unreadable. It can still be decoded by someone with motivation and plenty of spare time, but well, that's always the case for code that runs on the client, including binary executables. Just note here that obfuscated JavaScript is slow, or at least it takes a bit longer to load.

Here is a link with a few solutions: http://stackoverflow.com/questions/194397/how-can-i-obfuscateprotect-javascript[^].

Let me add a few more that are not included in the link above: if you're using Visual Studio, you probably have Dotfuscator, that's a great tool to obfuscate asp.net code and also regular JavaScript.

http://www.jsobfuscate.com[^] is one of several quick obfuscators that works in the browser (just copy and paste your JavaScript and push a button). If the size of the generated output is not a problem, this is a good tool.

Finally one of my favourites: http://jscrew.it[^] encodes any JavaScript using only 6 different characters on the fly (no need to push a button), has a Node.js module that can be run locally, and it can encode a file the size of jQuery (no, seriously[^]).

There are commercial solutions too, but I guess they're easy to find with Google if you look for "JavaScript obfuscation", although I don't recommend spending money for those tools.
This should be enough to get you started :-)


这篇关于如何阻止javascript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆