1
\$\begingroup\$

I want to make my game as fast as possible as it is real time and fast paced. I have already decided to encrypt my data here and I was wondering whether compressing it would be faster for the client and the server? Also I was wondering if it is better to encrypt data before or after compression.

asked Dec 10, 2014 at 12:01
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

It depends where the bottle neck is.

If you IO bound (the game is always waiting on network IO) then yes compressing will help.

If your game is CPU or memory bound then it will just run slower.

You should compress before encrypting because cipher text is less compressible as a result of trying to remove patterns that could be used to reverse engineer the cipher.

A better solution would be to make the protocol as compact as possible to begin with, for example by using a binary transfer method; binary data is easier to parse than text data and can be more compact (a double fits into 8 bytes while most doubles printed out take more than that).

answered Dec 10, 2014 at 12:07
\$\endgroup\$
6
  • \$\begingroup\$ Okay! What would the best method for encryption be? \$\endgroup\$ Commented Dec 10, 2014 at 12:24
  • \$\begingroup\$ AES with code block chaining is good enough \$\endgroup\$ Commented Dec 10, 2014 at 12:25
  • 1
    \$\begingroup\$ Just to add to your question : When sending binary data over sockets you have to watch out for different endianness ( talking about C/C++ and System APIs, Not sure about java ) \$\endgroup\$ Commented Dec 10, 2014 at 12:41
  • \$\begingroup\$ @EdoardoTygerDominici DataOutputStream does high byte first. And the ByteBuffers default to BIG_ENDIAN. \$\endgroup\$ Commented Dec 10, 2014 at 12:47
  • \$\begingroup\$ @ratchetfreak Sorry, misspoke. Meant to ask, "What would be the best method for compression?" \$\endgroup\$ Commented Dec 10, 2014 at 21:54

You must log in to answer this question.