Пример #1
0
    IEnumerator SQLLogin(string username, string password, SqlLoginCallback callback)
    {
        WWWForm form = new WWWForm();
        //URL Command
        string URL = loginURL + "username="******"&password=" + GenerateSHA256String(password);

        UnityWebRequest download = UnityWebRequest.Post(URL, form);

        //Send Request
        download.SendWebRequest();

        //Waiting for response
        while (!download.isDone)
        {
            yield return(new WaitForSeconds(0.2f));
        }

        //Read response
        ReaderHandlerLogin(download.downloadHandler.text, username, callback);
    }
Пример #2
0
    /*public static string GetStringFromHash(byte[] hash)
     * {
     *  StringBuilder result = new StringBuilder();
     *  for (int i = 0; i < hash.Length; i++)
     *  {
     *      result.Append(hash[i].ToString("X2"));
     *  }
     *  return result.ToString();
     * }
     *
     * public static string GenerateSHA256String(string inputString)
     * {
     *  SHA256 sha256 = SHA256Managed.Create();
     *  byte[] bytes = Encoding.UTF8.GetBytes(inputString);
     *  byte[] hash = sha256.ComputeHash(bytes);
     *  return GetStringFromHash(hash);
     * }*/
    #endregion

    #region Login
    public void Login(string _userName, string _password, SqlLoginCallback callback)
    {
        StartCoroutine(SQLLogin(_userName, _password, callback));
    }