隐藏源代码 [英] Hide source code

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

问题描述

Hi Ng,


有可能保护

的源代码一个js文件吗?用PHP?


提前致谢!


恩佐

解决方案

Enzo写道:

有可能保护
js文件的源代码吗?使用PHP?



不,没有什么可以阻止即使是中等智能的用户看到你的js源代码。微软可以选择加密js文件,但是(a)这意味着你的js只会在IE上运行,并且

(b)2分钟Google会为你找到一个解密js的实用工具。


你可以尝试使用javascript混淆器去除注释和空格

并用更短的替换有意义的变量名毫无意义的,但是

这样做的主要好处是它减少了下载时间,而且确实如果你需要调试任何东西,它会让你感到痛苦。




Enzo写道:

Ng,

有可能保护一个js文件的源代码?用PHP?

提前致谢!

恩佐




不是真的。

需要在用户计算机上执行js文件,因此代码以某种方式获得
。浏览器必须能够读取代码,如果浏览器可以使用
,那么用户也可以。

php与此无关,导致它在

服务器上运行,这是在其他地方。


micha


< blockquote>好的,谢谢,Duncan和Micha !!!


问候,


Enzo

Hi Ng,

It''s possible to protect the source code of
a js file? With PHP?

Thanks in advance!

Enzo

解决方案

Enzo wrote:

It''s possible to protect the source code of
a js file? With PHP?


No, there is nothing which you can do to stop even moderately intelligent
users from seeing your js source code. Microsoft have an option to
''encrypt'' js files but (a) this means your js will only ever run on IE, and
(b) 2 minutes with Google will find you a utility to unencrypt the js.

You can try using a javascript obfuscator to remove comments and whitespace
and replace meaningful variable names with shorter meaningless ones, but
the main benefit of this is that it reduces download times, and it does
make it more painful if you ever have to debug anything.



Enzo wrote:

Hi Ng,

It''s possible to protect the source code of
a js file? With PHP?

Thanks in advance!

Enzo



not really.
the js file needs to be executed on the users computer, so the code has
to get there somehow. the browser must be able to read the code, and if
the browser can, so can the user.
php has got nothing to do with that at all, cause it runs on the
server, which is somewhere else at all.

micha


Ok and thanks, Duncan and Micha!!!

Regards,

Enzo


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

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