Hot answers tagged

78

In general you should never invent your own cryptographic algorithms, unless you have at least a PhD in both mathematics and computer science. But there are many good stock algorithms which have no known attacks and have free implementations in many programming languages. For example RC5, AES or Blowfish. Depending on which technology you use to develop your ...


14

Answers SRP - Secure Remote Password - This is based on Diffie-Hellman. The idea is that you can do a mutual password check without actually ever transferring the password or any information that can be used to derive it. Even though it's secure over the wire you should still hash and salt your passwords as your server must never store them in plain text. ...


10

To encrypt and decrypt locally, you will need to store the key in your program, so people will be able to crack the encryption if they disassemble your code. There are tricks to obfuscate keys, but even with those a dedicated attacker will find the key and then post it online for all those who are less dedicated to see. The only thing encryption does prevent ...


8

What you ultimately end up using at runtime is going to be processed version of your exchange formats whether you do it offline or at runtime. The main differences are: If you do it at runtime then you're going to end up paying the processing cost repeatedly and You probably want to spend as little time processing and optimizing as possible so your load ...


7

Two observations: Your condition system seems to have two orthogonal axes: temperature and poison. Represent them as such. When thinking about this you should separate transitions from states. COLD and HOT are transitions in the way you mention them, not states. Combining those observations would result in something like this: // These is the ...


7

Use the organization of the data to your benefit. You can always be expect the data in the same order, so you know what the next bytes belong to. For example (not specific to your data), when reading in the data, always expect two bytes for tile type, two bytes for lighting information and then two bytes for extra info. So it knows that after 6 bytes, it's ...


6

When I need to use flags I usually do something along these lines. enum obj_state { NORMAL = 0x00000; DRY = 0x00002; HOT = 0x00004; BURNING = 0x00008; WET = 0x00010; COLD = 0x00020; FROZEN = 0x00040; POISONED = 0x00080; }; int objFlags; void DryOn() { objFlags |= DRY; } void ...


6

Without having read through all your code (or, indeed, being very familiar with .NET) and thus not knowing how appropriate this suggestion is: Make a wrapper around a class like MemoryStream, and add methods to objects that need to be serialized/deserialized. Don't just make a class that's an arbitrary bag of data. If you have a Widget class, it might read ...


5

Endianness matters when it comes to game consoles. The Wii, the PS3, and the XBox 360 all run big-endian, while all major desktop computers (as of the date I'm writing this answer) run little-endian. If there's a chance you'll want to compile your code for one of those game consoles someday, or if someone releases another popular big-endian desktop machine ...


4

Store a transformed SHA256 hash of the actual save data in the save file. Compare the stored hash to the SHA256 value of the data as you load it. If that doesn't match, they've cheated or corrupted the file. Edit to clarify: this makes it more difficult to crack the anti-cheat system but still possible.


4

There are lots of ways to handle the versioning problem; you can do it by having one load function per version, you can try to automate process by describing (via attributes usually) the transformation of the asset structure over time, you can do version-specific checks inside the load/save functions, et cetera. I like the "describe the changes" approach ...


3

What Byte56 says makes sense. I'm not sure why you need 2 separate coordinates (chunk coords and xy coords). But since a map is always square, the most basic representation is a 2D array of ascii chars ..,,.....@ ..,,@@@@@@ ...,,,...@ ......,..@ So there is the specification of a 4x10 map in 40 bytes. A 10,000 x 10,000 map would take 95MB, which isn't ...


3

I've implemented such offline format near month ago for my engine. The basic algorithm is: Write formal specification for output binary file in word processor. Header + data blocks. Data types, offsets, descriptions of each element of each block table. Write offline exporter from your 3D editor into C++ code text headers using embedded scripting language. ...


3

Representing your states as bitmask like you write, you can just translate your descriptions of the constraints into code: if ( (state & HOT) && (state & COLD) ) { state &= ~HOT; state &= ~COLD; // reset both HOT and COLD flags if both are set } if ( (state & COLD) && (state & WET) ) { state &= ...


2

I would use a standard encryption algorithm (because it makes it harder to perform crypto-analysis on the saved file) but not one of the top five most used, and hide it throughout your code (because it makes it harder to understand what algorithm it is and where is the key.) To hide the encryption algorithm into your code: take an open source version, ...


2

I think my last comment to Jonathan's otherwise excellent answer is worth expanding into an answer of its own: If you don't have a lot of crypto experience, you shouldn't try to design your own encryption layer if you can avoid it. If you do have a lot of crypto experience, you should know better than to design your own encryption layer if you can avoid ...


2

If you're concerned about performance, there's no reason to add additional operations to your setup. Especially operations containing hard disk read/writes as those are some of the slowest operations you can perform. Additionally, since it's running fine now, there's nothing to fix yet. You should start worrying about performance, when there's a performance ...


1

To answer the three of your questions with one answer: sure you could, but you wouldn't be able to use the default content manager. However, you can create custom content processors to output file data in a format that only you would immediately know. This would still allow you to use the default XNA content manager (this.Content in any Game-derived class) ...


1

Use a markup language with attribute-value pairs like XML or JSON. The parser can just ignore any attributes it doesn't understand or use defaults for any it doesn't find, which makes backward- and forward compatibility quite easy. Also, the format is human-readable so you can easily edit it with a text editor. When you use an established language like ...


1

I would use something like ProtoBuf with RPC support.



Only top voted, non community-wiki answers of a minimum length are eligible