如何保护/隐藏来自用户的Javascript方法或JS文件,查看 [英] How to protect/Hide Javascript method or JS file from user to view

查看:176
本文介绍了如何保护/隐藏来自用户的Javascript方法或JS文件,查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何保护我的JS实现从用户的方法呢?所以没有人能复制这些方法。通常情况下,用户可以看到萤火虫JS方法很容易。我想隐藏的萤火虫方法也。 有没有什么诀窍隐藏方法从用户?

注意:我不想使用eval方法。所以请不要认为我给eval基础的技巧

解决方案
  1. 尝试装箱code / minifiying它

谷歌关闭编译器是一个良好的开端

也有一个YUI lib中,你可以使用等等。

这会使你的code pretty的太多不可能在Firebug调试。

目前虽然能阻止用户与您的code碴没有充分论证的方式,因为它运行在定义客户端。

  1. 您可以做的另一件事是把你要隐藏的闭包里面的方法,这样用户只需倾斜从萤火运行的someMethod(),并把它执行code。

How can I protect my implemented JS methods from user? So that no one could copy these methods. Normally, User can see JS methods in firebug easily. I want to hide methods in firebug also. Is there any trick to hide methods from users?

Note: I don't want to use Eval method. so please don't suggest me to eval based tricks

解决方案

  1. try packing the code/minifiying it

google closure compiler is a good start

there is also a YUI lib that you can use and many others.

This will make your code pretty much impossible to debug in firebug.

There is no full proof way though to stop users for mucking with your code, since it does run on the client side by definition.

  1. Another thing you can do is put the methods you want to hide inside of a closure, so that the user cant simply run someMethod() from firebug and have it execute code.

这篇关于如何保护/隐藏来自用户的Javascript方法或JS文件,查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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