开发者

how to hide javascript code [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

How can I obfuscate JavaScript?

Hello!

Is it possible to hide JS code? How? I read somewhere a technique like: take JS to external file, and use js-encrypt.

I know that is impos开发者_JAVA百科sible to hide from all eyes, but...

Thank you.


It is not possible to hide Javascript from the user, since their browser needs to download it to execute it. The only other option is obfuscation.


You can run your private JavaScript server side e.g. using ASP JScript.NET

<% WebService Language="JScript" Class="MyClass" %>

You can put the hidden functionality on the server and call it via AJAX in the non hidden part of the code on the client.

you can also use

<script runat="server">

or if you're not using a Microsoft platform you might consider Mozilla Rhino


As you can take someone else's code and try to encrypt it, same goes for others who can take your code. The only solution that i think is to obfuscate your javascript code so that it becomes little difficult for others to grasp but there again there decryptors available so no real solution as of what i know has come about so far.


The simple answer is no - since the browser needs to understand the javascript, then the user will be able to understand the javascript...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜