C# MD5加密

/// 
/// MD5加密
/// 
/// 待加密字符串
/// 加密后字符串
public static string MD5Encrypt(string strText)
{
    MD5 md5 = new MD5CryptoServiceProvider();
    byte[] targetData = md5.ComputeHash(Encoding.UTF8.GetBytes(strText));

    string byte2String = null;

    for (int i = 0; i < targetData.Length; i++)
    {
        byte2String += targetData[i].ToString("x2");
    }

    return byte2String.ToUpper();
}

你可能感兴趣的:(C# MD5加密)