导航

数据库连接加密

Posted on 2011-01-07 09:55  口渴的火麒麟  阅读(532)  评论(0编辑  收藏  举报

 Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
            ConfigurationSection configSection = config.GetSection("connectionStrings");
            if (configSection.SectionInformation.IsProtected)
            {
                //如果已经加密,就不用再加密了
                Label1.Text = "已经加密!";
            }
            else
            {
                configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                config.Save();
                Label1.Text = "加密成功!";
            }