国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ASP.NET2.0中配置文件的加密與解密

2019-11-18 17:08:07
字體:
來源:轉載
供稿:網友

首先添加引用: using System.Web.Configuration;

加密操作如下:
PRivate void ProtectSection(string sectionName, string provider)
    {
        Configuration config =
            WebConfigurationManager.
                OpenWebConfiguration(Request.applicationPath);

        ConfigurationSection section = config.GetSection(sectionName);

        if (section != null && !section.SectionInformation.IsProtected)
        {
            section.SectionInformation.ProtectSection(provider);
            config.Save();
        }
    }

解密操作如下:
 private void UnProtectSection(string sectionName)
    {
        Configuration config =
            WebConfigurationManager.
                OpenWebConfiguration(Request.ApplicationPath);

        ConfigurationSection section = config.GetSection(sectionName);

        if (section != null && section.SectionInformation.IsProtected)
        {
            section.SectionInformation.UnprotectSection();
            config.Save();
        }
    }
實踐:
加密前的配置文件:
<?xml version="1.0"?>
<configuration>
    <appSettings>
  <add key="name" value="shy520" />
  <add key="address" value="VEVb" />
 </appSettings>
    <system.web>
        <compilation debug="true"/>
  </system.web>
</configuration>
加密后的配置文件:
<?xml version="1.0"?>
<configuration>
    <appSettings configProtectionProvider="DataProtectionConfigurationProvider">
  <EncryptedData>
   <CipherData>
    <CipherValue>
      AQAAANCMnd8BFdERjHoAwE/Cl+s
      BAAAABi1ATlNkEUGEf0XyWGL2Xg
      QAAAACAAAAAAADZgAAqAAAABAAA
      ABIhxMWlazAntwIIpST1CDXAAAA
      AASAAACgAAAAEAAAAPz/YKYx07c
      b+h4fqdr4fkLgAAAAX1Ieyc+WSx
      AfsDW1vn2C/fXsG2TAnYeUgaCov
      8e3nGFTHHsH91gLiqKregFPYzGR
      vW1xrez/3VwOmJI9eS7EFKrcXej
      NnHL66kg2iNRk3ntLNZlZtTs3cZ
      9w63u47VKAjs6miWsGBz2GntL/9
      UGHLELigrJcr3YJ+lsjOscExQnv
      HGvA48EfxpD+tEiFBtgXeHsFkQX
      cqGySshx16vCt2GUNUC3ZmEAhBh
      UsAFkPIYqelYHd4+m9a/xPe2tqw
      GIbla1wbW2NDEfrzJPwnkfmpNqR
      hXijKImipwXbDVYy6o0UAAAAs8D
      suYNOhJ7qAjJa2c/4eUC7sks=
      </CipherValue>
   </CipherData>
  </EncryptedData>
 </appSettings>
    <system.web>
        <compilation debug="true"/>
  </system.web>
</configuration>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西吉县| 呼伦贝尔市| 买车| 玉龙| 如东县| 义乌市| 福鼎市| 定州市| 元谋县| 广饶县| 商丘市| 哈尔滨市| 莫力| 南和县| 静乐县| 布尔津县| 定边县| 资源县| 太仓市| 阿坝| 开封县| 甘德县| 东至县| 临沭县| 石阡县| 青海省| 孟村| 泽州县| 资溪县| 瑞昌市| 江陵县| 民权县| 嘉定区| 峡江县| 莱芜市| 朝阳区| 延川县| 上栗县| 泸溪县| 承德县| 通山县|