using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace XYY.Core.Standard
{
    public static class MD5Util
    {
        public static string Get(string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return null;
            }
            string str2 = "";
            var gb2312encode = Encoding.GetEncoding("GB2312");
            byte[] buffer = MD5.Create().ComputeHash(gb2312encode.GetBytes(str));
            for (int i = 0; i < buffer.Length; i++)
            {
                str2 = str2 + buffer[i].ToString("X2");
            }
            return str2;
        }
        public static string Get(string str, Encoding encoding)
        {
            string str2 = "";
            byte[] buffer = MD5.Create().ComputeHash(encoding.GetBytes(str));
            for (int i = 0; i < buffer.Length; i++)
            {
                str2 = str2 + buffer[i].ToString("X2");
            }
            return str2;
        }
    }
}
