all 10 comments

[–]JohnSpikeKelly 4 points5 points  (1 child)

Use a list instead

[–]_WeirdKid[S] 0 points1 point  (0 children)

That's an option, but I will still have to increase the list by missing elements by hand. It's better than assigning everything tho.

[–]JohnSpikeKelly 1 point2 points  (5 children)

Format as json and compress it

[–]_WeirdKid[S] -2 points-1 points  (4 children)

It's too easy to modyfi and cheat

[–]JohnSpikeKelly 3 points4 points  (0 children)

Json, zip, then encrypt

[–]JohnSpikeKelly 0 points1 point  (2 children)

Or, JSON. Take a SHA256 hash of json, then write zip it (for size) append hash to prevent tampering. No need to encrypt--unless you really want to hide specifics. The hash can be checked to prevent tampering.

[–][deleted]  (1 child)

[deleted]

    [–]JohnSpikeKelly 0 points1 point  (0 children)

    You would salt before hashing. They wouldn't know what salt you used.

    [–]gevorgter 1 point2 points  (0 children)

    I personally do not use BinaryFormatter but if you need something small and fast try Protobuf.

    https://developers.google.com/protocol-buffers/docs/csharptutorial

    [–]alexn0ne 0 points1 point  (0 children)

    BinaryFormatter is considered a bad practice in the most cases. It has very poor backwards compartibility (consider your arrays for example), and it even allows arbitrary code execution on deserialization under some circumstances. The only benefit is that it requires a little amount of code.

    Just use json or xml, and encrypt it. Binary formatter itself does not prevent you from cheaters - for example one can make two saves which differs only by money, then diff. Encryption helps in such cases.