- I'm working on a server based game and I'm sending my game data via a JSON from the server to the clients.
- To minimize bandwidth use, I cache the game data JSON on the client machine so that they do not need to download the JSON from the server everytime.
- I need to know if the JSON cached on the client is the same as the one on the server (it can become different either when we make changes on the server or if the user accessed and tweaked the cache on the client side).
So basically I need some kind of hashing technique to get a key unique to a JSON string that I can check to see if the JSON cached on the client is the same as the one stored on the server. The server will send that hash first to the client and only if it differs from the one generated from the client cache, then the client will request the whole JSON from the server again.
- I do not care about data loss as the hash will never be converted back to string again.
- I do not care about Hash difference due to different key orders in the JSON as I make sure they are always in the right order when I get the JSON from the server.
- The hash shouldn't be environment specific. The same algorithm should generate the same hash regardless of environment, 32 or 64 bit and endianness.