using System;
using System.Security.Cryptography;
using System.Text;
public class UnityUtil
{
    /// <summary>
    /// MD5Encrypt
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static string MD5Encrypt(string str)
    {
        MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
        byte[] hashedDataBytes;
        hashedDataBytes = md5Hasher.ComputeHash(Encoding.GetEncoding("gb2312").GetBytes(str));
        StringBuilder tmp = new StringBuilder();
        foreach (byte i in hashedDataBytes)
        {
            tmp.Append(i.ToString("x2"));
        }
        return tmp.ToString();
    }


    public static string getCountdown(int s)
    {
        string hour;
        string min;
        string sec;
        TimeSpan ts = new TimeSpan(0, 0, s);
        if (ts.Hours < 10)
        {
            hour = "0" + ts.Hours;
        }
        else
        {
            hour = "" + ts.Hours;
        }
        if (ts.Minutes < 10)
        {
            min = "0" + ts.Minutes;
        }
        else
        {
            min = "" + ts.Minutes;
        }
        if (ts.Seconds < 10)
        {
            sec = "0" + ts.Seconds;
        }
        else
        {
            sec = "" + ts.Seconds;
        }
        return hour + ":" + min + ":" + sec;
    }

}
