- private static byte[] ToByteArray(object value)
- {
- byte[] result = new byte[] { };
- string val = value as string;
- if (val != null)
- result = new System.Text.UnicodeEncoding().GetBytes(val);
- return result;
- }
- public static string Tomd5(string value)
- {
- byte[] hash = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(ToByteArray(value));
- string result = System.BitConverter.ToString(hash);
- result = result.Replace("-", "");
- return result;
- }
- //该片段来自于http://www.codesnippet.cn/detail/261120137510.html
来源: http://www.codesnippet.cn/detail/261120137510.html