I'm working on a multiplayer game using WebSockets. I've decided all user data will be stored on the client, eliminating the need for authentication using passwords etc.
LocalStorage
'save' -> '{"key":"value", "key2":"value2"}'
'hash' -> '<hash of save>'
The idea is to store the user data in plain text but to also store a hash which can only be calculated by the server (running Node.JS). The client will send both save
and hash
to the server to be checked and loaded into memory for this session.
Now, my question is:
- If I use SHA256 to hash all the
save
data, how can I prevent a user from generating their own hash for the data? - Then, (assuming the answer to part 1 is 'salt',) will using salt keep me safe or can this be calculated? (I can make the salt partly different for each user)