Although not very fresh, but believe that there are many people do not know, good, do not say nonsense, directly to the method: Start---> Run, enter cmd, and then enter the following content
Encryption:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe-pef "connectionstrings" "Your Web Project path"
Decrypt:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe-pdf "connectionstrings" "Your Web Project path"
. NET is modified for the version path, where connectionstrings the name of the connection string.
It is important to note that a native-based key is used in the encryption process, which means that the decryption process must be done on the same computer. If you move the encrypted Web.config file to another computer, the connection string in the Web.config file will not be decrypted properly.
With encryption before and after comparison:
1. Before encryption
<configuration>
<connectionStrings>
<add name= "ConnectionName" connectionstring= "server= 127.0.0.1;database=testdb; User Id=sa; Password=ok "
providername=" System.Data.SqlClient "/>
</connectionStrings>
</ Configuration>
2. After encryption
<configuration> <connectionstrings configprotectionprovider= "RsaProtectedConfigurationProvider" > < EncryptedData type= "http://www.w3.org/2001/04/xmlenc#Element" xmlns= "http://www.w3.org/2001/04/xmlenc#" > &L T 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# "> <encryption Method algorithm= "Http://www.w3.org/2001/04/xmlenc#rsa-1_5"/> <keyinfo xmlns= "http://www.w3.org/2000/09/x"
mldsig# "> <keyname>rsa key</keyname> </KeyInfo> <CipherData> <ciphervalue>fdfw3bnvt21rf3n39vdopphemdybux4cmcid/3+lmy0yrlhckyulnnybloflb7dujyxxms0v33e7mokt+u2taocn6x+ Qho9z4onf1fv0neq6utprwz04m8slbkp+vg63jltyquft6xf+bi/an/zj3pyal93bdfnjjtxa2xsb82k=</ciphervalue> </Ciph Erdata> </encryptedkey> </KeyInfo> <CipherData> <ciphervalue>92westbhbh0zeu705wseruajhahumv9ucrm Fjwii8srhqpjedrsl0oafhwyfenr4xphsfkndtefvv5d4mxr3memsccp+oyeqxq/mg1qyle9mgd+ neabnv95wzadcddye1sknkkq01px94ouv1oygsqtex1fczd6le8fd7kx4pafkdd0he6ajznfmcofxg1dd1+ Md3mukgfef64nbjyovtnw8v2g67wle8vnrokxivs6+0+rnplepdayiedal2d3jjwncqrl+uxi=</ciphervalue> </CipherData
> </EncryptedData> </connectionStrings> </configuration>