CS文件密码加密类

private string _PasswordFormat;

        public Security(string PasswordFormat)

        {

            //

            // TODO: 在此处添加构造函数逻辑

            //PasswordFormat

            this._PasswordFormat = PasswordFormat;

        }

 

        public string EncryptPassword(string PasswordString)

        {

            if (_PasswordFormat == "SHA1")

            {

                return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString, "SHA1");

            }

            else

            {

                if (_PasswordFormat == "MD5")

                {

                    return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString, "MD5");

                }

                else

                {

                    throw new Exception("Error Password Fromat define.");

                }

            }

        }

posted @ 2013-12-13 17:02  简单就好。。。  阅读(558)  评论(0编辑  收藏  举报