国产探花免费观看_亚洲丰满少妇自慰呻吟_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>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 珲春市| 枞阳县| 双桥区| 巨鹿县| 利辛县| 泸州市| 抚顺县| 扬中市| 九龙县| 汕头市| 奇台县| 天津市| 永吉县| 沁源县| 汤阴县| 溧阳市| 兴化市| 天峻县| 华池县| 潮安县| 黄骅市| 刚察县| 津市市| 会宁县| 清流县| 邵东县| 山阳县| 通辽市| 农安县| 句容市| 石景山区| 翁牛特旗| 泰顺县| 恩施市| 新和县| 金溪县| 库伦旗| 望都县| 淮安市| 正镶白旗| 庆元县|