【问题标题】:Unity 3D secure authentication with SQL使用 SQL 的 Unity 3D 安全身份验证
【发布时间】:2023-03-27 23:53:02
【问题描述】:

我正在开发一个统一 3d 的 android 应用程序,它将为用户帐户更新所述帐户以及控制应用程序后端的所有内容提供网络通信。我统一使用 WWW 类将信息发送到服务器。后端是php,所有数据都存储在mysql数据库中。我如何才能在应用程序和后端之间建立安全连接,而无需有人只是简单地获取服务器地址并将其阻止在他们的主机文件中并提供应用程序虚假信息并使用它上网。(例如)我没有安全感专家,但我不确定我还需要查看什么才能在服务器和客户端之间创建安全连接。任何帮助都会得到极大的帮助。谢谢。

【问题讨论】:

    标签: c# php android mysql unity3d


    【解决方案1】:

    你只需要实现 www 类

          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
                        }
    
    
                }
        else
            Debug.Log("error");
    }
    

    }

    【讨论】:

    • 谢谢老兄!!我更了解身份验证!我会给你+1,但不能:(!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 2011-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多