I’m trying to build a client/server game using PHP as server and I want to exchange cryptographed messages in order to increase secure. I thought of RSA to be very hard to discover the private key. RSA works fine in PHP, but in Unity it doesn’t work. I used RSACryptoServiceProvider, but when I change the keys, seems like there is no changes at all. This class seems to always generate random keys.
Had any one worked with that?
You gain no real benefit from using asymmetric encryption. It’s better to use a symmetric single pass algorithm such as MD5.
The reason I say this, is the ease with which there is key discovery in a Unity application as you can extract the source code. In addition to them being a hell of a lot faster and thus more suited to realtime streaming.
There is a highscores example on the Unity wiki which demonstrates what you’re trying to accomplish. There is also an MD5 class for you to use.
Also there is a lengthy discussion of security and possible ways to hide hash strings/keys that would be worth reading.
Thanks, Quietus!
I’ve been working on trying to use assymetric key for a week, but now I think will follow your advice.
Just one thing, you said: “the ease with which there is key discovery in a Unity application as you can extract the source code”. In that case, assymetric keys would be the solution, wouldn’t they? Since Unity client have the public key, and PHP server have the private key.
Anyway, I use the solution you suggested. I think anyone that want to hack my game won’t go that deep.