Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Adding on to what Larry said, you're definitely going to have to handle the scoring on the backend to really prevent cheating/fake score posting.</p> <p>For an example of this in practice... The game <a href="http://wordwars.clay.io" rel="nofollow">Word Wars</a> is a boggle-esque game where you find as many words as you can from a 4x4 grid of letters. </p> <p>At the start of each game, a 4x4 board is generated server side. A list of possible words for that board is generated and a hashed version (md5'd with a random salt) of each word as well as the salt are passed to the client. </p> <p>On the client side, when the letters are typed and the enter key is pressed, we md5 (with the salt from the server) the word that was entered and check that against the list of hashed words provided by the server. If it's a match, we update the client with the new score (there's a function based on letters used and their point values).</p> <p>Once the game is over, the client sends the list of words they came up with to the server (NOT the score), and the server double-checks that those words existed in the board, and handles the scoring.</p> <p>This is where Clay.io, the company I'm working in comes in. Clay.io offers an API for high level HTML5 game features like leaderboards, achievements, payment processing, etc... Needless to say, we needed a solution for games that have a backend to make certain things like high scores more secure.</p> <p>The solution was to encrypt JavaScript objects on the backend (node.js, php, whatever) using JWT (JSON Web Token), and pass that encrypted object rather than the score itself. This lets us communicate both ways (game -> Clay.io and Clay.io -> game), and is pretty painless to do. The full docs on this are here: <em>clay.io/docs/encryption</em> (max links hit on this answer)</p> <p>Back to Word Wars... from the server we generate that JWT with the user's score and pass that on to Clay.io to post the score. Voila :)</p> <p>Of course, this will differ as the type of game you're developing differs, but the moral of the story is you have to get creative :)</p> <p>I wrote a blog post that covers HTML5 game security in greater detail. <a href="http://blog.clay.io/html5-game-development-tips-part-3" rel="nofollow">Part 3 of a series on HTML5 Game Development Tips</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload