当前位置: 代码迷 >> ASP.NET >> 怎么对web.config配置文件的configuration类加密
  详细解决方案

怎么对web.config配置文件的configuration类加密

热度:4526   发布时间:2013-02-26 00:00:00.0
如何对web.config配置文件的configuration类加密
怎么加密~~
要实例~

------解决方案--------------------------------------------------------
private void EncryptConfig(bool bEncrypt)
{
string path = "/Test ";
Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
ConfigurationSection appSettings = config.GetSection( "connectionStrings ");//appSettings这样加密appSettings
if (bEncrypt)
{
appSettings.SectionInformation.ProtectSection( "DataProtectionConfigurationProvider ");//加密
}
else
{
appSettings.SectionInformation.UnprotectSection();//解密
}
config.Save();

}
  相关解决方案