First, I know that there is no 100% sure solution, and this question have been ask more than once.
These posts are my favorites first and second but they are too old without enough effective solutions.
I'm creating a social game in JavaScript, HTML5 and CSS3 and I use canvas. For security reasons I wanted to know how to detect if a user is using his debugger tool. To prevent if a user is trying to change some value, speed etc.. but I can handle most of these stuff with PHP.
My game is a real-time game.
This is the non-exhaustive list of some anti-cheat ideas:
- Check values every time he earns points on server side to see if it's consistent.
- Crypt each value then decrypt it on server side.
- Have a different Hash for each value and make it random each time a user load the game.
- Minify and Encode my whole script file.
- Detect if a user is using a debugger and check if he is resizing his window during the game (but he could open his debugger before loading the game so..).
- Make the page submit a complete replay of the game and check for inconsistencies.
- for each request to the server, send the script and compare it with the original script in case user has modified it.
- Put the script minified inside my html page and for each request, send back the orignal script to replace the actual one.
- Put a timer on client side, send the time on server side when you want in order to check if values are consistent (to do it you could calculate if the score match a minimum time you have set, e.g: the time is at 47sec, the score is 1000 and for your game between 40sec && 50sec the score can not be more than 1500 so in this case all is fine).
Of course there is many more solutions to list.
For each solution, he will have access to his debugger tool. There is no proper way to totally prevent the use of a debugger tool. So there is no way to prevent at 100% a user not to cheat.
At least you can make an almost anti-cheat by grouping all of these solutions together. Even if you don't have a full working system, only a small part of your users will cheat, and you can be sure that you will find tutoriel about how to cheat on your game, so you'll be able to find solution each time it happens.