C#实现MD5加密32位,补0和不补0区别
程序员文章站
2022-07-14 07:57:41
...
/// <summary>
/// 获取32位MD5加密字符串(已补完0)
/// </summary>
/// <param name="strWord"></param>
/// <returns></returns>
public static string GetMD5String(string strWord)
{
string strRes = string.Empty;
MD5 md5 = MD5.Create();
byte[] fromData = System.Text.Encoding.UTF8.GetBytes(strWord);
byte[] targetData = md5.ComputeHash(fromData);
for (int i = 0; i < targetData.Length; i++)
{
strRes += targetData[i].ToString("X2");//x不补0,x2把0补齐,X为大写
}
return strRes;
}
上一篇: 字符串匹配之KMP算法
下一篇: 字符串匹配之KMP