Highscore table Help

Hey guys…

To be sincere, I have no idea how this works…

I have this, to send the data to the SQL base:

IEnumerator PostScores(string name, int score)
    {
        string hash = Md5Functions.Md5Sum(name + score + secretKey);

        string post_url = addScoreURL + "name=" + WWW.EscapeURL(name) + "&score=" + score + "&hash=" + hash;

        WWW hs_post = new WWW(post_url);
        yield return hs_post;

        if (hs_post.error != null)
        {
            print("There was an error posting the high score: " + hs_post.error);
        }
    }

Now, when I had this Md5Functions, it worked fine:

public  static 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');
}

But because I had to compile it to be upload to the Metro Store, I had to replace the Md5Functions for this code:

using UnityEngine;
using System.Collections;

#if UNITY_METRO
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
#else
using System.Text;
using System.Security.Cryptography;
#endif

public static class Md5Functions
{
    static string md5val;

    static void Start()
    {
        md5val = Md5Sum("Hello World!");
        Debug.Log(md5val);
    }

    static void OnGUI()
    {
        GUILayout.Label(md5val);
    }

    public static string Md5Sum(string strToEncrypt)
    {
#if UNITY_METRO
       
        // Convert the message string to binary data.
        IBuffer buffUtf8Msg = CryptographicBuffer.ConvertStringToBinary(strToEncrypt, BinaryStringEncoding.Utf8);
       

        // Create a HashAlgorithmProvider object.
        HashAlgorithmProvider objAlgProv = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5);

        // Demonstrate how to retrieve the name of the hashing algorithm.
        string strAlgNameUsed = objAlgProv.AlgorithmName;

        // Hash the message.
        IBuffer buffHash = objAlgProv.HashData(buffUtf8Msg);

        // Verify that the hash length equals the length specified for the algorithm.
        if (buffHash.Length != objAlgProv.HashLength)
            return null;

        // Convert the hash to a string (for display).
        string strHashBase64 = CryptographicBuffer.EncodeToBase64String(buffHash);

        // Return the encoded string
        return strHashBase64.PadLeft(32, '0');
#else
        UTF8Encoding ue = new UTF8Encoding();
        byte[] bytes = ue.GetBytes(strToEncrypt);
      
        // encrypt bytes
        MD5CryptoServiceProvider md5 = new 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');
#endif
    }
}

And, of course, now, there is no data send to the SQL database…

Can someone help me out, telling me what do I have to change either in the Md5 or in the sending data script, for it to work, please???

The problem maybe here… I guess…

<?php
        $db = mysql_connect('mysql', 'user', 'pass') or die('Could not connect: ' . mysql_error());
        mysql_select_db('sql_db') or die('Could not select database');
        // Strings must be escaped to prevent SQL injection attack.
        $name = mysql_real_escape_string($_GET['name'], $db);
        $score = mysql_real_escape_string($_GET['score'], $db);
        $hash = $_GET['hash'];
        $secretKey="mySecretKey"; # Change this value to match the value stored in the client javascript below

        $real_hash = md5($name . $score . $secretKey);
        if($real_hash == $hash) {
            // Send variables for the MySQL database class.
            $query = "insert into scores values (NULL, '$name', '$score');";
            $result = mysql_query($query) or die('Query failed: ' . mysql_error());
        }
?>

So, how can I connect the Md5Function with the data sending script and the AddScores.php?

(Of course, I have in my php the real user name, pass and sql db)