English 中文(简体)
保险单中的功能长度
原标题:Get length of a function in javascript

I m使用 no子和现在js。 我想获得把这一功能称作服务器的功能的全时长度,如果情况相同,则进行检查。 防止用户操纵客户的辅助功能。 可能排除可能改变的变量。 是否有办法在 j中做到这一点?

页: 1

客户

now.sendMessage() {
    //Some code...
}

服务器

everyone.now.sendMessage() {
    //Check that the code is the exact length 
    //as the function body written in the 客户side script
    //To see if it has been manipulated...
    if (codelength === ?) {
        //execute code
    } else {
       //return error
    }
}
最佳回答

可做到这一点:。 http://jsfiddle.net/RsrCB/1/

But in practice, it s not reliable. JavaScript code can t be checked for integrity for several reasons:

  • It s easy to obfuscate it
  • It s easy to override the integrity-checking code
问题回答

为此:

   var codelength =  (String(yourfunction_name).length);

有了这种知识,你也可以在职能单位中计算出一些洗衣物,并进行比较。

你现在就错了。 我们不能信任用户。

With now you just define procedures on the client and call them with some data. You do not pass sensitive data like this.

你发给客户的任何数据都属于客户,你不能躲避劫持。

now uses websockets or XHR underneath. Your simply sending data to a client on a socket, it can be intercepted.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签