username@email.com
2022-01-21 b18a7c8e54b51a5caa400e55cb8cc428c0301a0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Security.Cryptography;
using System.Text;
 
namespace JumbotCms.API.Tenpay
{
    /// <summary>
    /// MD5Util µÄժҪ˵Ã÷¡£
    /// </summary>
    public class MD5Util
    {
        public MD5Util()
        {
            //
            // TODO: ÔÚ´Ë´¦Ìí¼Ó¹¹Ô캯ÊýÂß¼­
            //
        }
 
        /** »ñÈ¡´óдµÄMD5Ç©Ãû½á¹û */
        public static string GetMD5(string encypStr, string charset)
        {
            string retStr;
            MD5CryptoServiceProvider m5 = new MD5CryptoServiceProvider();
 
            //´´½¨md5¶ÔÏó
            byte[] inputBye;
            byte[] outputBye;
 
            //ʹÓÃGB2312±àÂ뷽ʽ°Ñ×Ö·û´®×ª»¯Îª×Ö½ÚÊý×飮
            try
            {
                inputBye = Encoding.GetEncoding(charset).GetBytes(encypStr);
            }
            catch (Exception ex)
            {
                inputBye = Encoding.GetEncoding("GB2312").GetBytes(encypStr);
            }
            outputBye = m5.ComputeHash(inputBye);
 
            retStr = System.BitConverter.ToString(outputBye);
            retStr = retStr.Replace("-", "").ToUpper();
            return retStr;
        }
    }
}