Search Unity

Hide a String in Server-Build ?

Discussion in 'Scripting' started by iSleepzZz, Sep 14, 2020.

  1. iSleepzZz

    iSleepzZz

    Joined:
    Dec 23, 2012
    Posts:
    206
    Hi guys!
    So I would love to find some sort of #IF statement when building for server or client.
    Because I have a string stating my MySQL username and password, and would love to build an empty string in the client-build so I do not leak my information :)

    If anyone knows, thanks in advance!
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    I'd encourage you to put your database credentials in a separate configuration file that you put on your server along with the executable for a few reasons:
    • No chance of accidentally compiling it into your client.
    • You can change your db credentials simply by changing the file, no code changes or rebuild necessary.
    • You can include other configuration information in it too, such as the URL for your database, that you also don't want to share with the client.
     
    iSleepzZz likes this.
  3. iSleepzZz

    iSleepzZz

    Joined:
    Dec 23, 2012
    Posts:
    206
    That is an awesome idea, will do that. Thanks! :)