加密数据

//加密数据,以SHA1/MD5两种方法
        public static string GetEncrypt(string strData, string strType)
        {
            if (strType.ToUpper() == "SHA1")
            {
                strData = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strData, "sha1");
            }
            else if (strType.ToUpper() == "MD5")
            {
                strData = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strData, "md5");
            }
            return strData;
        }

调用

string Password;

Password = Pulic.GetEncrypt(Password, "MD5");

posted @ 2013-07-10 12:05  活生  阅读(141)  评论(0)    收藏  举报