编码/保护javascript代码的最佳方法是什么? [英] What is the best way to encode/protect a javascript-code?

查看:93
本文介绍了编码/保护javascript代码的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何混淆JavaScript?

Possible Duplicate:
How can I obfuscate JavaScript?

我想保护"我的Javascript代码.有什么好推荐的方法很难破解吗?

I want to "protect" my Javascript code. Are there any good, recommended ways which are very difficult to hack?

我在网络上测试了一些编码器,有时我的Javascript代码在编码后不起作用. 这是正常现象吗(编码器非常糟糕)?...还是我的代码太糟糕/越野车?

I tested some encoder on the Web and sometimes my Javascript code doesn't work after encoding. Is this normal (cot the encoder is very bad)?... or is my code too bad/buggy?

推荐答案

您不能阻止任何人查看您的JavaScript代码.它基本上与html相同.您可能很难破译(也就是混淆),但您从中实际上一无所获.

You can't prevent anyone from looking at your javascript code. Its basically the same as html in that way. You can make it very difficult to decipher, aka obfuscation, but you really gain nothing from this.

如果您有出于某种原因认为关键任务至关重要的应用程序关键代码,请以在服务器上运行受保护"代码的方式设计Web应用程序.使用xhr请求与前端(浏览器)进行通信,这些请求仅来回传递状态数据.

If you have application critical code that for whatever reason you feel is mission critical, design your web app in such a way that the "protected" code is run on the server. Communicate to the front-end (the browsers) using xhr requests that are only passing state data back and forth.

这篇关于编码/保护javascript代码的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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