本文介绍了需要加密javascript die roller输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在制作一个javascript程序,用于滚动骰子进行角色扮演 游戏,这是在论坛中播放的。生成的掷骰子,在隐藏的表格字段中作为文本存储,然后在表单提交时写入mySQL 数据库。 我想做的是防止作弊者自己创建自己的掷骰子,而我想出的最好的方法就是 加密存储在隐藏表单字段中的内容。但是,由于用户可以查看所有 javascript代码,因此他们可以看到我使用的键是什么键。 任何关于用什么作为用户无法访问的密钥的建议 to?数据硬编码成java applet,也许?即使那可能是某个人可以在运行时检查javascript变量 的工具可以攻击。 它只是简单如果我的代码在 javascript中,则无法防止作弊?必须有一些方法来保护隐藏的表单字段 ,以确保他们的内容只是代码生成。在那儿?或者是否有一些其他的方法来制作防骗的javascript模具滚轮我还没有想到的是什么? Hi, I''m making a javascript program for rolling dice for a roleplayinggame that''s played in a forum. The die roll gets generated, gets storedas text in a hidden form field, and then gets written to the mySQLdatabase upon form submission. What I want to do is prevent cheaters from being able to create theirown die roll, and the best way I''ve come up with to do this is toencrypt what gets stored in the hidden form field. However, since alljavascript code can be viewed by the user, they can see what key I''musing. Any suggestions on what to use as a key that a user cannot get accessto? Data hard-coded into a java applet, perhaps? Even that might behackable by someone a tool capable of inspecting javascript variablesat run-time. Is it simply impossible to prevent cheating if my code is injavascript? There must be some way to secure hidden form fields toinsure that their content is code-produced only. Is there? Or is theresome other way to make a cheater-proof javascript die roller I haven''tthought of? 推荐答案 任何在客户端生成数据的方法都可能被劫持;你需要 来使用服务器端代码。如果用户需要在提交表单之前能够看到模具 滚动,那么您应该在显示表单之前生成它并将其包含在页面中(存储结果 在数据库中,所以用户无法改变它,或使用一些单向或 时间相关的加密技术,所以如果他们试图改变它你可以找出)。 - 萨法拉(斯蒂芬莫利) http://www.safalra.com/programming/javascript/ 糟糕的选择。您正在有效地创建客户端/服务器应用程序 ,其中客户端完全由用户控制。 在这种情况下,您无法信任客户端。 /> Bad choice. You are effectively making a client/server applicationwhere the client is under the complete control of the user.In that situation, you can not trust the client. 的确如此。无论浏览操作是什么,用户都可以修改它来做其他事情,比如将对Math.random的调用更改为一个总是 返回1.0。 Indeed. No matter what the browse does, the user can modify it to dosomething else, like changing a call to Math.random to one alwaysreturning 1.0. 在服务器上掷骰子。这是确保[1] Roll the dice on the server. It''a the only way to be sure[1] 是的。更重要的是,当客户直接生成随机数时,不可能防止作弊。 你可以让客户创建一个随机的数字,然后通过在服务器上计算的数字来抵消 ,但是你可以直接使用服务器生成的数字来获得。 Yes. More to the fact, it''s impossible to prevent cheating whenthe client genrates the random number directly. You could make the client create a random number, and then offsettingit by a number computed on the server, but then you could justuse the server generated number directly. 不可能,而且没有。 客户端脚本的安全模型允许完全控制 在页面上,即使没有,任何表单提交都可以伪造 并使用简单的telnet连接。 There mustn''t, and there isn''t.The security model of client side scripting allows full controlover the page, and even if not, any form submission can be fakedwith a simple telnet connection. 滚动服务器,然后将数字发送给客户端作为提交的响应的一部分 。 / L [1],从轨道上钻取网站。 - Lasse Reichstein Nielsen - lr*@hotpop.com DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/ rasterTriangleDOM.html> ''没有判断的信仰只会降低精神神圣。'' Roll on the server, then send the number to the client as part ofthe respons of the submission./L[1] that, and nuking the site from orbit.--Lasse Reichstein Nielsen - lr*@hotpop.comDHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>''Faith without judgement merely degrades the spirit divine.'' 在服务器上创建一个rollDice函数,并从客户端 进行AJAX调用。 rollDice一次性滚动并将值存储在服务器上, ,只需将眼睛的数量返回给客户端进行显示。 - Dag。 Create a rollDice function on the server, and make an AJAX call fromthe client. The rollDice rolls and stores the value on the server in one go,and just return the number of eyes to the client for display. --Dag. 这篇关于需要加密javascript die roller输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-25 04:37