Webconfig加密解密
加密步骤:
1.以管理员身份进入cmd.exe
2.输入cd C:\Windows\Microsoft.NET\Framework\v4.0.30319(相应Framework版本所在路径)
3.输入aspnet_regiis.exe -pef "需要加密的节点" "相应的web.config所在的路径"(例如aspnet_regiis.exe -pef "connectionStrings" "D:\WebSite-Adult")
解密步骤:
1.以管理员身份进入cmd.exe
2.输入cd C:\Windows\Microsoft.NET\Framework\v4.0.30319(相应Framework版本所在路径)
3.输入aspnet_regiis.exe -pdf "需要解密的节点" "相应的web.config所在的路径"(例如aspnet_regiis.exe -pdf "connectionStrings" "D:\WebSite-Adult")
注:加密解密只能在一台电脑上操作,否则不可逆。
加密前:
<connectionStrings>
<add name="RMDataConnectString" connectionString="server=; port=3307;database=user;uid=root;password="
providerName="MySql.Data.MySqlClient" />
</connectionStrings>
加密后:
<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>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
</CipherData>
</EncryptedData>
</connectionStrings>