web.config 节点的加密
2009-10-31 00:06
399 查看
web.config 节点的加密
using System.Web;
using System.Web.Configuration;
using System.Configuration;
using System;
namespace King
{
public class ProtectedWebConfigs
{
public bool ProtectedWebConfig()
{
return false;
}
public bool ProtectedWebConfig(string sectionName)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
string provider = "RsaProtectedConfigurationProvider";
if (!config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.ProtectSection(provider);
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
public bool ProtectedWebConfig(string sectionName, string path)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
string provider = "RsaProtectedConfigurationProvider";
if (!config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.ProtectSection(provider);
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
public bool UnProtectedWebConfig(string sectionName)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
if (config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.UnprotectSection();
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
public bool UnProtectedWebConfig(string sectionName, string path)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
if (config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.UnprotectSection();
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
}
}
命令行加密方法
aspnet_regiis -pe (加密的节,如connectionString) app /虚拟目录
命令行解密方法
aspnet_regiis -pd (加密的节) app /虚拟目录
RsaRrotectedConfigurationProvider
2009-10-31-00:08:20
using System.Web;
using System.Web.Configuration;
using System.Configuration;
using System;
namespace King
{
public class ProtectedWebConfigs
{
public bool ProtectedWebConfig()
{
return false;
}
public bool ProtectedWebConfig(string sectionName)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
string provider = "RsaProtectedConfigurationProvider";
if (!config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.ProtectSection(provider);
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
public bool ProtectedWebConfig(string sectionName, string path)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
string provider = "RsaProtectedConfigurationProvider";
if (!config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.ProtectSection(provider);
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
public bool UnProtectedWebConfig(string sectionName)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
if (config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.UnprotectSection();
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
public bool UnProtectedWebConfig(string sectionName, string path)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
if (config.GetSection(sectionName).SectionInformation.IsProtected)
{
config.GetSection(sectionName).SectionInformation.UnprotectSection();
try
{
config.Save();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
return true;
}
}
}
}
命令行加密方法
aspnet_regiis -pe (加密的节,如connectionString) app /虚拟目录
命令行解密方法
aspnet_regiis -pd (加密的节) app /虚拟目录
RsaRrotectedConfigurationProvider
2009-10-31-00:08:20
相关文章推荐
- web.config文件中节点加密解密
- .Net学习笔记 - Web.config节点加密
- asp.net 在webConfig中对某个节点加密和解密
- 对 web.config 节点信息进行加密
- 给web.config节点加密
- web.config 配置节点加密
- 给web.config节点加密
- 加密 web.config
- 加密 web.config
- ASP.NET 2.0加密Web.config 配置文件
- WebConfig加密/解密
- WebConfig加密解密
- asp.net webconfig文件节点介绍
- 配置文件(Web.Config)加密解密详细说明
- 加密Web.Config文件
- web.config 加密解密--简洁版
- web.config中customErrors节点的配置
- Web.config配置文件节点及属性
- asp.net中web.config配置节点大全详解
- ASP.NET web.config个节点详解