1 public String md5(String s)
2 {
3 System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
4 byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
5 bytes = md5.ComputeHash(bytes);
6 md5.Clear();
7
8 string ret = "";
9 for(int i=0 ; i<bytes.Length ; i++)
10 {
11 ret += Convert.ToString(bytes[i],16).PadLeft(2,'0');
12 }
13
14 return ret.PadLeft(32,'0');
15 }
2 {
3 System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
4 byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
5 bytes = md5.ComputeHash(bytes);
6 md5.Clear();
7
8 string ret = "";
9 for(int i=0 ; i<bytes.Length ; i++)
10 {
11 ret += Convert.ToString(bytes[i],16).PadLeft(2,'0');
12 }
13
14 return ret.PadLeft(32,'0');
15 }