回复:(airfei)如何加密Web.config中的mailSettings...
对了,我Web.config的结构是这样的
<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件以外,您还可以使用
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
“网站”->“Asp.Net 配置”选项。
设置和注释的完整列表在
machine.config.comments 中,该文件通常位于
\Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration>
<appSettings 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>thR8rs01AXQ5xXWziZvxNRlKAZGd5peIDae2js06VGNQGs3Dy+FmTdiGsvN3vM2/s37FRGlZspeEnhQN2O6nQgVSiwFVt/4yEmh0mmMAlFOn1XIR6nyDTP6o2n5GD0l6JR2t+2W5RvGG9y65GtnqF0MoXOik1u630n8CIFn/m3s=</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>svDsHZWfyEUjGRnxqQBbdyClDs4jdJESv4ogsf46IZ0hosTrPGCcOu3EOYJbvkw4aJqAWnJsPklpaIKp5UHawBIJ4d9ZNtkFbY6yHQvb8oCcTT1K2NOiGafwIV+M0TkUuBWVtiDV3hJ5RfUO59amJ46JZtJBSo1I</CipherValue>
</CipherData>
</EncryptedData>
</appSettings>
<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>mwDwwE0TxdGJN54ohSxOa747UtdafObdwNwOIe0OWEKSLs9ng29oGToLG+04CIgsmKC9tvmiyT4oYGsLJQ1Ac8YiLy/yhaDetz5oDhTHPkTY8WphM7HdyEL1Ue8Dky17CmOmALFAxZFl7uJVXUpvdNbaSw+OzhUZFZkfbngU5xs=</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>mEiiOI1VgBCYJ2AvDngRaIegfMYO8akR5gz3xK0mPf2jNigO7kXSOvon9vViAhSKKrvuqoaYgUSgfJeUyI9kImyk0Hx5HlpUjwdrwcV8BxycjY7MXey3qXqsGm/j9dYuWzM1c57920Wli/RjZsUKA+IPj3bep3vQ/r56YP8GHF8VU6bIL0KL3ZzRndR+sSgjM1N4S/ZiTepL+3qykSE9eZjd5Rr8deeD1+FWQfoRsnk90D296JUIItkPEvGeSF/gpyCu5GyojACcvmnrUkHYcE0SOrOQ1Hg3</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
<system.web>
<httpRuntime executionTimeout="3600" maxRequestLength="524288"
useFullyQualifiedRedirectUrl="true" minFreeThreads="8"
minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
<!--
设置 compilation debug="true" 将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<compilation debug="true"/>
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,
以标识传入的用户。
-->
<authentication mode="Windows"/>
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
-->
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
<sessionState timeout="60"/>
<globalization requestEncoding="gb2312" responseEncoding="gb2312" />
</system.web>
<system.net>
<mailSettings>
<smtp from="***@126.com">
<network host="220.181.15.112" password="***" userName="***" />
</smtp>
</mailSettings>
</system.net>
</configuration>