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

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:13:01
字體:
來源:轉載
供稿:網友


收集最實用的網頁特效代碼!

首先添加引用: 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="cnblogs" />
 </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>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 进贤县| 叙永县| 松潘县| 翁源县| 澜沧| 芦溪县| 靖江市| 会东县| 牡丹江市| 北川| 理塘县| 德昌县| 荆州市| 腾冲县| 利津县| 湘潭县| 大英县| 沁源县| 南溪县| 钟山县| 昌邑市| 旬邑县| 东莞市| 湟中县| 霍邱县| 许昌县| 洛南县| 马公市| 包头市| 许昌市| 沿河| 深泽县| 三河市| 肃南| 磐安县| 沽源县| 东乡县| 仁怀市| 双江| 黔南| 察雅县|