日期:2014-05-20  浏览次数:20404 次

如何对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();

}