木其网络科技专业程序员代写http://www.xmsydw.com
程序员学历擅长经验网店链接
apenny硕士ASP.NET PHP 电子 通信设计 图像 编程 网络5年进入店铺
zheng_qianqian本科C语言 C++面向对象 Java5年进入店铺
guoguanl本科Java Web项目 JSP Hibernate Struts Mysql5年进入店铺

PetShop 4.0知识点:加密和解密Web.config文件的配置节

PetShop 4.0 中Web.config文件中的连接字符串是加密的,需要进行解密才能看到。

这个问题PetShop 4.0的ReadMe文件中有说明:

 

Encrypting and Decrypting the Connection Strings

Run <Pet Shop 4 Install Folder>\EncryptWebConfig.bat or DecryptWebConfig.bat to encrypt or decrypt connection strings in Web.config.

Note: If you select the “Full Install” option during setup, Web.config is automatically encrypted. Use DecryptWebConfig.bat should you need to decrypt it.

 

EncryptWebConfig.bat 和 DecryptWebConfig.bat是批处理文件,可用记事本打开,查看命令的具体内容。

 

 

 

 

 

可新建一最简单的网站Web1,把PetShop的Web.config文件复制过来。在IIS建个虚拟目录web1指向这个网站,然后,“开始”→ “运行”→ “cmd“,打开控制台程序,

在路径:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 中,运行:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -pd "connectionStrings" -app "/web1"
正在解密配置节...
成功!

解密后的连接字符串如下:

  <connectionStrings>
    <add name="SQLProfileConnString" connectionString="server=SPXY-WYH\sqlexpress;database=MSPetShop4Profile;integrated security=SSPI;min pool size=4;max pool size=4;"
      providerName="System.Data.SqlClient" />
    <add name="SQLMembershipConnString" connectionString="server=SPXY-WYH\sqlexpress;database=MSPetShop4Services;integrated security=SSPI;min pool size=4;max pool size=4;"
      providerName="System.Data.SqlClient" />
    <add name="SQLConnString1" connectionString="server=SPXY-WYH\sqlexpress;database=MSPetShop4;integrated security=SSPI;min pool size=4;max pool size=4;"
      providerName="System.Data.SqlClient" />
    <add name="SQLConnString2" connectionString="server=SPXY-WYH\sqlexpress;database=MSPetShop4;integrated security=SSPI;max pool size=4;min pool size=4;"
      providerName="System.Data.SqlClient" />
    <add name="SQLConnString3" connectionString="server=SPXY-WYH\sqlexpress;database=MSPetShop4Orders;integrated security=SSPI;min pool size=4;max pool size=4;"
      providerName="System.Data.SqlClient" />
    <add name="OraProfileConnString" connectionString="" providerName="System.Data.OracleClient" />
    <add name="OraMembershipConnString" connectionString="" providerName="System.Data.OracleClient" />
    <add name="OraConnString1" connectionString="" providerName="System.Data.OracleClient" />
    <add name="OraConnString2" connectionString="" providerName="System.Data.OracleClient" />
    <add name="OraConnString3" connectionString="" providerName="System.Data.OracleClient" />
  </connectionStrings>

 

也可以反过来对这个连接字符串进行加密:

运行:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -pe "connectionStrings" -app "/aaa" -prov "RsaProtectedConfigurationProvider"
正在加密配置节...
成功!

 

加密后的连接字符串:

  <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>aCLHvPwcwd2iz97a5HQUYFVh7pwMy7fpecNsvLNlh3Xtz3KXRRDtPO8P3HjMRgv2OrAmGoCw2Kza98J+zmbgkpFx34j2vToBa8mTWsUh1UEMcvf93I/of4jnVxwZBZdB+x/Oe1wK9LzyNN9D3xYjP8TZybBKmXW8p8hb1f3KkQY=</CipherValue>
          </CipherData>
        </EncryptedKey>
      </KeyInfo>
      <CipherData>
        <CipherValue>c5y28XZS4D+35b7Yv+RU8jMsE3iSOESXJ4gHkAC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0+byVz3LGtFjcmZ5+vyMa+vcQI6h82cCKLfucBrVzncKg6DNk1JGZrgfY6ayb5ZfrDzRsXNJjeBiCzfn5pCXHI65vDp/25hJ6ApBL3RtHfDF5IpREnQ8titst4wi4jjJKfOWnugtbiFIs4NaLpay/XDm8o6B38vhqxGkaPPXGJMEdq7D1rnAeFzm0A3O5o8hD2lA56kmo+yXKCuPvhig6I5H77tv/0QpWsdg3ajohORlGGEEhOP8vN6Askn+9nWbjVVjhCihC0fwupv7lHv3TU2Dtm2Al7xxXDcvZ6TWW/XK4eUQJlzjAr1X9wjI5RKBr46ACcZj2iVwFBO+HNuO8wxh/cxuZiDAWHUtMpfs5XEYO0YtldK0BHGkv3tH/ZYpxaFXHp5tEiAPUEo//YU5aVfrXDRS1rUdOS/uTRUgNsusP97fF2FdvpzaThKReLaz6lAjjByuXAdX3r0B6ATPNJ3i5WLb46JzoqRM2AaiIzzEmTyEeY0FlYRiDu80vQdr+oncEvS+Vgyc/1bfOVlj3BvTI07vZE3paJvHa6LKjNtXsf90JGOBZjmpMiSCOhI2SNLniFp+F0t99Ne5/GVPZNUz5NLkf6x3c9myuZHGQ5LBoH1gOc4HKvv30/vbPRyIE9CK6wPX/s7+UXZ6fpA5agu74yoDT3rGk0BdtU7B/XOsybzDfu3jbWMzRh/ZNepq6yvxGhTlVPToCx+H1De0Sdkq+oLri/JxZTBsPxNeU1Fp9Nb9au4RimRoX9AWDFe6skQarhXZIOS0IwzWGi4snGAYVrLwnF8H5/BUunfQYbH5RnEhvrhfxF6/98mlfYBuvgb4KFz58sSyOXwSgfHcycnwgUI7G5Gk8rwV5P0goFYZJnepYW7i1NUfor4mCmu8090iLmyvbhOIyUZwalXsCefgOoP2gmIjYV7HuXXSawM7HSKGR633GdREBa/BT89G67UYMB</CipherValue>
      </CipherData>
    </EncryptedData>
  </connectionStrings>

 

上面命令中,“-pe“选项表示对Web.config文件加密;“-app“选项可标识奖其加密为Web.config文件的应用程序,如果末使用“-prov"选项指定提供程序,将使用配置为DefaultProvider的提供程序。(加密结果会不一样吧...)

 

参考书目:茅健编著.ASP.NET 2.0+SQL Server 2005全程指南.北京:电子工业出版社,2008

posted @ 2011-10-30 19:23  程序流程图  阅读(455)  评论(0编辑  收藏  举报
木其网络科技专业程序员代写http://www.xmsydw.com
程序员学历擅长经验网店链接
apenny硕士ASP.NET PHP 电子 通信设计 图像 编程 网络5年进入店铺
zheng_qianqian本科C语言 C++面向对象 Java5年进入店铺
guoguanl本科Java Web项目 JSP Hibernate Struts Mysql5年进入店铺