I have coded a basic game in JavaScript and am working on a high score system for it, however as it is coded in JavaScript we all know it is incredibly easy to open Firebug or Chrome’s Dev tools and edit the code. For example adding a multiplier to the score.
Does anyone know either
A) a way to check the JavaScript hasn’t been modified and/or
B) a secure way to post the scores
There is nothing you can do. The script itself would be responsible for checking, and so can not be trusted.
Generally, people decide either to a) not care enough, and remove obviously fake high scores if they appear, b) log on the server-side how long the user was on the page before submitting to see if it was reasonable, or c) take the more arduous path of logging all game actions, sending those, and replaying the game on the server (probably in combination with option B).
However, those protect on a very basic level. To some extent, all you can do is make it not worth one’s while to attack you; you can’t ever prevent it entirely.