private static string tottt(string s) { byte[] source = md5.ComputeHash(Encoding.UTF8.GetBytes(s)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < source.Length; i++) { sBuilder.Append(source[i].ToString("x2")); } return sBuilder.ToString(); } private static string tottt2(string s) { byte[] source = md52.ComputeHash(Encoding.UTF8.GetBytes(s)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < source.Length; i++) { sBuilder.Append(source[i].ToString("x2")); } return sBuilder.ToString(); } private static string tottt3(string s) { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(s, "MD5").ToLower(); }
测试在使用Encoding.UTF8时,三个方法计算结果是一致的
时间: 2024-10-26 01:48:48