求C#高手帮忙也 错误原因:上下文不存在MD5 怎么改呀

2025-05-06 00:17:36
推荐回答(5个)
回答1:

你对象名都有问题.肯定不存在啊...
给你一个以前写的.:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;

namespace BLL
{
public class Encrypt
{
///


/// MD5加密
///

/// 要加密的值
///
public static string Md5(string str)
{
try
{
byte[] hashvalue = (new MD5CryptoServiceProvider()).ComputeHash(Encoding.UTF8.GetBytes(str));
return BitConverter.ToString(hashvalue);
}
catch
{
return String.Empty;
}
}
}
}

回答2:

MD5的Dll未添加为引用,或者在此代码所在源文件中 未对 MD5的命名空间使用Using

回答3:

你没有引用System.Security.Cryptography

回答4:

引用using System.Security.Cryptography;

回答5:

你刚开始学写程序啊? 方法名和实例化的对象名都重复了,那怎么用啊...