| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class DatabaseController : MonoBehaviour
- {
- private string secretKey = "TheNarKampenSecretKey";
- public string questionURL = "http://nordh.xyz/narKampen/Questions.php?";
- public string categoriesURL = "http://nordh.xyz/narKampen/Categories.php?";
- public Text statusText;
- public IEnumerator getQuestion()
- {
- Question question = new Question();
- WWW getQuestion = new WWW(questionURL);
- yield return getQuestion;
- if (getQuestion.error != null)
- {
- print("There was an error getting question: " + getQuestion.error);
- }
- else
- {
- statusText.text = getQuestion.text;
- }
- }
- public string Md5Sum(string strToEncrypt)
- {
- System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
- byte[] bytes = ue.GetBytes(strToEncrypt);
- // encrypt bytes
- System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
- byte[] hashBytes = md5.ComputeHash(bytes);
- // Convert the encrypted bytes back to a string (base 16)
- string hashString = "";
- for (int i = 0; i < hashBytes.Length; i++)
- {
- hashString += System.Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
- }
- return hashString.PadLeft(32, '0');
- }
- }
|