private string GetMD5Hash(string str) { string md5Str = ""; byte[] buffer = Encoding.UTF8.GetBytes(str); MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] cryptBuffer = md5.ComputeHash(buffer); //把每一个字节 0-255,转换成两位16进制数 for (int i = 0; i < cryptBuffer.Length; i++) { //大写X转换的是大写字母,小写X转换的是小写字母 md5Str += cryptBuffer[i].ToString("X2"); } return md5Str; }
时间: 2024-10-18 00:11:53