class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetMd5("123"));
//202cb962ac5975b964b7152d234b70
}

    public static string GetMd5(string str)
    {
        MD5 md5 = MD5.Create();
        byte[] strbf = Encoding.Default.GetBytes(str);
        byte[] md5bf = md5.ComputeHash(strbf);
        //字节数组--字符串
        //1.按照编码格式解析
        //2.ToString()
        //3.将数组元素的每个元素ToString();
        //return Encoding.Default.GetString(md5bf);
        string strec = "";
        for (int i = 0; i < md5bf.Length; i++)
        {
            strec += md5bf[i].ToString ("x");//默认10进制"x":十六进制

        }
        return strec;
    }
}