Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

RSA encryption

Discussion in 'Scripting' started by joaobsneto, Jul 6, 2010.

  1. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    Hi Guys!

    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?

    Thanks!
     
  2. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    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.

    http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores

    Also there is a lengthy discussion of security and possible ways to hide hash strings/keys that would be worth reading.

    http://forum.unity3d.com/viewtopic.php?t=18253
     
    taxvi likes this.
  3. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    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.
     
  4. hitmax87

    hitmax87

    Joined:
    May 27, 2013
    Posts:
    12
  5. taxvi

    taxvi

    Joined:
    Feb 18, 2013
    Posts:
    30

    Updating links. The first link is Server Side Highscores on wiki.unity3d.com >> http://wiki.unity3d.com/index.php/Server_Side_Highscores

    I could not find the other one