2014-04-26 10:31

使用SQL进行Unity 3D安全身份验证


I'm developing an android application in unity 3d that will have network communications for user accounts updating said accounts as well as controlling everything on the back end of the app. I use the WWW class in unity to send info to the server. The backend is php and all the data is stored in a mysql database. How can I make a secure connection between the app and the backend without someone just simply getting the servers address and blocking it in their hosts file and feeding the app false info and going online with it.(as an example) I'm no security expert but I'm not sure what I need to look in too in order to create secure connections between server and client. Any help would be greatly apericiated. Thank you.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dphe5602 dphe5602 7年前

    you just need to implement the www class

          void start()
            StartCoroutine(retrieveHighscores()); //Start out by getting the current scores.
        IEnumerator retrieveHighscores()
        var form = new WWWForm(); // create a new form
        form.AddField("Nipun",name); // add the data you want to retrieve in the form fields
        var rawData = form.data;
        var headers = form.headers;  // here headers will be used to authenticate the credentials of the person trying to access
        headers["Authorization"]="Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("username:password"));
        WWW webRequest = new WWW("https://abc.com/test.php", rawData, headers); // 
        yield return webRequest;
        if (webRequest != null) {
      //here you have successfully got the response back from the server , here i am adding the whole response in a string and then splitting the string based on the format of the data i received.
                        string x = webRequest.text;
                        string[] lines = webRequest.text.Split(new string[] { System.Environment.NewLine }, System.StringSplitOptions.RemoveEmptyEntries); //Split the response by newlines.
            Debug.Log(x); // to check what you received
                        scores = new Dictionary<string, int>(); //Always reset our scores, as we just got new ones.
                        foreach (string line in lines) //Parse every line
                            // code here how you want to use the split up data you received


    点赞 评论 复制链接分享