今天做一個求字元串MD5加密的小程式,建立了一個C#控制台應用程式,輸入下面代碼
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace 求md5
{
class Program
{
static void Main(string[] args)
{
string str = GetMd5("xuwei");
Console.WriteLine(str);
}
public static string GetMd5(string str)//求MD5
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8,16);
}
}
可是老是報"命名空間"system.web"中不存在類型或命名空間名稱security"錯誤,我想在程式前端加上
using System.Web應該就可以了,可惜還是不行,後來一查才知道是應該在引用中添加System.Web才行。如圖
本文轉自xwdreamer部落格園部落格,原文連結:http://www.cnblogs.com/xwdreamer/archive/2010/01/02/2297177.html,如需轉載請自行聯系原作者