namespace OubHackMS.Crypto
{
    using System;
    using System.Security.Cryptography;
    using System.Text;

    internal class MD5L
    {
        public static byte[] computeHash(string sString)
        {
            using (MD5 md = MD5.Create())
            {
                return md.ComputeHash(Encoding.ASCII.GetBytes(sString));
            }
        }

        public static byte[] computeHash(byte[] bString)
        {
            using (MD5 md = MD5.Create())
            {
                return md.ComputeHash(bString);
            }
        }

        public static string sComputeHash(string sString)
        {
            byte[] buffer = computeHash(sString);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < buffer.Length; i++)
            {
                builder.Append(buffer[i].ToString("x2"));
            }
            return builder.ToString();
        }

        public static string sComputeHash(byte[] bString)
        {
            byte[] buffer = computeHash(bString);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < buffer.Length; i++)
            {
                builder.Append(buffer[i].ToString("x2"));
            }
            return builder.ToString();
        }
    }
}

