.NET加密配置文件connectionStrings节点-阿里云开发者社区

开发者社区> 阿笨net> 正文

.NET加密配置文件connectionStrings节点

简介: 具体的可以参考petshop源码程序。 加密前: View Code   加密后: ...
+关注继续查看

具体的可以参考petshop源码程序。

加密前:

  <connectionStrings>
    <add name="SQLProfileConnString" connectionString="server=(local);user id=mspetshop;password=pass@word1;database=MSPetShop4Profile;min pool size=4;max pool size=4;packet size=3072"
    providerName="System.Data.SqlClient" />
    <add name="SQLMembershipConnString" connectionString="server=(local);user id=mspetshop;password=pass@word1;database=MSPetShop4Services;min pool size=4;max pool size=4;packet size=3072"
    providerName="System.Data.SqlClient" />
    <add name="SQLConnString1" connectionString="server=(local);user id=mspetshop;password=pass@word1;database=MSPetShop4;min pool size=4;max pool size=4;packet size=3072"
    providerName="System.Data.SqlClient" />
    <add name="SQLConnString2" connectionString="server=(local);user id=mspetshop;password=pass@word1;database=MSPetShop4;min pool size=4;max pool size=4;packet size=1024"
    providerName="System.Data.SqlClient" />
    <add name="SQLConnString3" connectionString="server=(local);user id=mspetshop;password=pass@word1;database=MSPetShop4Orders;min pool size=4;max pool size=4;packet size=1024"
    providerName="System.Data.SqlClient" />
    <add name="OraProfileConnString" connectionString="Data Source=localhost;user id=MSPETSHOPPROFILE;password=pass@word1;min pool size=4;max pool size=4"
    providerName="System.Data.OracleClient" />
    <add name="OraMembershipConnString" connectionString="Data Source=localhost;user id=MSPETSHOPMEMBERSHIP;password=pass@word1;min pool size=4;max pool size=4"
    providerName="System.Data.OracleClient" />
    <add name="OraConnString1" connectionString="Data Source=localhost;user id=MSPETSHOP;password=pass@word1;min pool size=4;max pool size=4"
    providerName="System.Data.OracleClient" />
    <add name="OraConnString2" connectionString="Data Source=localhost;user id=MSPETSHOP;password=pass@word1;min pool size=4;max pool size=4"
    providerName="System.Data.OracleClient" />
    <add name="OraConnString3" connectionString="Data Source=localhost;user id=MSPETSHOPORDERS;password=pass@word1;min pool size=4;max pool size=4"
    providerName="System.Data.OracleClient" />
  </connectionStrings>
View Code

 

加密后:

  <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
    <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
      xmlns="http://www.w3.org/2001/04/xmlenc#">
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
          <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
          <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
            <KeyName>Rsa Key</KeyName>
          </KeyInfo>
          <CipherData>
            <CipherValue>toBlOJmJmZ/3SYJaltdhQA/RfrSAwf633228VBzG0ZUeTq2jsJksoxQID0GVozH3AQbfbIVoXdg0KsPgLpT3a+Xi5KGvWwyurrNqt0cPBCvWoBRtQLoc5ni87hbqDFaxSTrS9xX2kIpeC91QE1lA+l7Kk9e48YaJxPw82ZnzgUM=</CipherValue>
          </CipherData>
        </EncryptedKey>
      </KeyInfo>
      <CipherData>
        <CipherValue>yFoUrcd3MH3tsgquIezF6sfaI2rZKlxYDRX58m0jdgKTNK1hpwItSbcPbqioyHu251OKH38kI0IBUNE1VMr6vBqGEmnZyZjI77ZBkJWg6wNjW84Ul2TuyM0uQodpUabC+7v4vKtzrVMQ6Og3gShqsg8XEQqCZ+R5fS8xFNDlVhxEL1PmexiYuamc4Gple8RdnVnGyqWRsAxuphu00zGmQxuD6ZCUnk2riBYb7XVHM5jzX42u4a1gYG581HQwFCPDl2hP2+grfFKt+DJc23o0ceARY02bJJ0Z0wX1Cn2TIx/WK1vFqKgxE0/s9sd8rg+EOdpaXLWYG3QWhlA/LgIKgSvcevCLPX+N+p1i/RYVOEanlNAca8tvQazXWGdabDc+tl6XdViKMwgUJntnMEm1+C5xQEo4V+ImqYwSMyUqqUGrMWQQeYe9kLVFGXdTO+fizMRX1IVenCKykOE3SZHHw0BMlUBVpXw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/du9dwkzLPfwume3RsOjws2vgTbz2JN7GFQOiPooDoOWvCzNUkZBzUa4Mb5qGH2y7jST2sT/X0+bY+shakavxUz0woCt1QfCvRq1lipmPIohRyj+Xw+QvQQkDSDSiZjE/ZXda25IHUO0tEJhAoajW8FYEcdECPhCSGptcizTPsmhUkS1BC9qykqG6vpgZ6C+C8=</CipherValue>
      </CipherData>
    </EncryptedData>
  </connectionStrings>
View Code

 

EncryptWebConfig.bat加密批处理代码:

@echo off
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" "D:\Program Files\Microsoft\.NET Pet Shop 4.0\Web"
PAUSE
View Code

 

DecryptWebConfig.bat解密批处理代码:

@echo off
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pdf "connectionStrings" "D:\Program Files\Microsoft\.NET Pet Shop 4.0\Web"
PAUSE
View Code

 

直接将语句拷贝到.BAT文件中,D:\Program Files\Microsoft\.NET Pet Shop 4.0\Web 为相应的web.config所在的路径,只能在一台电脑上操作,否则不可逆!

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
SQL必知必会(一)
对于我们而言,数据库是一个以某种有组织的方式存储的数据集合。最简单的办法就是将数据库想象成一个文件柜。这个文件柜是一个存放数据的物理位置,不管数据是什么,也不管数据是如何组织的。 数据库(DataBase) 保存有组织数据的容器(通常为一个或一组文件)
2 0
学习报告——冬季实战营第一期:从零到一上手玩转云服务器
训练营日期:2022年1月17日 - 2022年1月23日
39 0
阿里云ecs使用体验
整了台服务器部署项目上线
10 0
+关注
842
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载