Code
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Security.Cryptography;
5
6namespace Archives
7{
8 public static class Encryption
9 {
10 /**//// <summary>
11 /// MD5加密
12 /// </summary>
13 /// <param name="str"></param>
14 /// <returns></returns>
15 public static string MD5(String str)
16 {
17 MD5 md5 = new MD5CryptoServiceProvider();
18 byte[] data = System.Text.Encoding.Default.GetBytes(str);
19 byte[] result = md5.ComputeHash(data);
20 String ret = "";
21 for (int i = 0; i < result.Length; i++)
22 ret += result[i].ToString("x").PadLeft(2, '0');
23 return ret;
24 }
25 }
26}
27
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Security.Cryptography;
5
6namespace Archives
7{
8 public static class Encryption
9 {
10 /**//// <summary>
11 /// MD5加密
12 /// </summary>
13 /// <param name="str"></param>
14 /// <returns></returns>
15 public static string MD5(String str)
16 {
17 MD5 md5 = new MD5CryptoServiceProvider();
18 byte[] data = System.Text.Encoding.Default.GetBytes(str);
19 byte[] result = md5.ComputeHash(data);
20 String ret = "";
21 for (int i = 0; i < result.Length; i++)
22 ret += result[i].ToString("x").PadLeft(2, '0');
23 return ret;
24 }
25 }
26}
27