question

ariellarias avatar image
ariellarias asked

Hashing on Cloudscript

Hi.

This is probably not only cloudscript/playfab related, but I'm looking a good way to do content hash in cloudscript (content = player internal/not internal variables, or cloudscript constants).

What I want to do is check the hash of the same content in the client (unity) and the server/cloudscript.

I've tried adding a md5 implementation as a function into the cloudscript and works for most of the cases, but sometimes the hash doesn't match (I assume is something like encoding...?)

Do someone did something like this before in cloudscript? Is any good way to import libraries into cloudscript for this? Any ideas are welcome.

Thanks in advance!

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Could you describe in more detail what your goals are? We may be able to suggest a better approach.

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ariellarias avatar image ariellarias commented ·

Thanks for the prompt answer!

What I'm doing currently is to load from the cloudscript some configuration objects. We only load them once when players start, and they're saved in the device.

But if we change something (most of them are description texts and stuff like that) we want the player to query again and overwrite the local data. That's why, we were comparing local hash and server hash for the same object, if differs, then bring the server object and overwrite it locally.

These objects are not too huge, but still we wanted to avoid to just ask for them all the time and only if needed.

0 Likes 0 ·
brendan avatar image brendan ariellarias commented ·

I guess my first question would be, why not just use a version number, in that case?

0 Likes 0 ·
ariellarias avatar image ariellarias brendan commented ·

Good question! We thought about that but in some specific cases, some data is important for gameplay and can be "touched" in the locally saved data... the version number will not change but if we use hash that could be detected

0 Likes 0 ·
Show more comments
ariellarias avatar image ariellarias commented ·

Hi, sorry for the delay.

We solved it by creating custom hash functions on both sides (Unity and Cloudscript) that uses the same Encoding. The problem was encoding, for some strings, it did'nt worked as expected so we needed to make sure that the encoding was always the same. It sounds obvious.. but we still needed to figure it out :P

I hope can be useful for someone in the future :)

(btw, thanks Brendan for always answering everything in record time! You are one of the reasons why we love PF :) )

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.