WinForm encryption and decryption of configuration files
Direct input under the Visual Studio command Prompt (2010) window:
Decrypt
Aspnet_regiis-pdf connectionStrings program folder full directory
Encryption
ASPNET_REGIIS-PEF connectionStrings program folder full directory
Note: The configuration file name must be changed to Web. config during encryption and decryption
Program operation must be changed back App.cong
You can also switch to the command prompt by running cmd and go to C:\WINDOWS\Microsoft.net\Framework\v2.0.xxxx,
Where xxxx is the version of the framework you are using, you can get it by opening the above directory.
=================================================
Configuration file: Before encryption
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<connectionStrings>
<add name= "str1" connectionstring= "Data source=127.0.0.1;database=customerservicedb;
Uid=sa;pwd=123 "/>
</connectionStrings>
</configuration>
===================================
Configuration file: After encryption
===================================
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<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>uqupayvda7wowewwg1foftuhqudglmkmggqbdgceawbdoqzjdrqzru9/tyr1gt0qhnap5tam/2po1safq
EHVA6A3YVUADDHJXYDPNX5YII0O5SXSSWZCRE7KWFPHKOK6RSIMEQJGVDFEKWFHWGJDUSIIL1TURPMCCL6HFPTP
+ns=</ciphervalue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<ciphervalue>w9cu5aenhpo4oavzyogic3cy9nqdfkutn4oaxynmp/ibffwdqbbjav/h7pgurn+
+gwjt9t9ibktwllkd0/meb2iidmuvwedlywxnzvpacbyzri1tllkf6od0vlkkeqxghd6vh+aam
+zypwkttzkrrait6uxxozinz7clwxezwyfmx+zz7+ob8hbh0rw0ehn2bq4djhysrow98dpublmnjw==</ciphervalue>
</CipherData>
</EncryptedData>
</connectionStrings>
</configuration>
WinForm encryption and decryption of configuration files