Xpode.com        Click here to Print this article.

Encryption/Decryption of Connection String in asp.net2.0

Usually connection string in web config is not encrypted. For security purpose in asp.net 2.0 or upper version there is a functionality to encrtypt the connection string. The .NET Framework have two protected configuration providers:

* RSAProtectedConfigurationProvider - uses the asymmetric RSA algorithm for encryption and decryption.

* DPAPIProtectedConfigurationProvider - uses the Windows Data Protection API (DPAPI) for encryption and decryption.

In this example we have made two methods for encryption and decryption and called on buttons. In working example you just need to extract the example and open as website and run. Changes will be seen in webconfig of example.

There are two main functions in example named:
1) ProtectSection
2) UnProtectSection

When you want to encrypt the connection string then call the first function and when you want to check the original values of the connections then call second function.

Encryption/Decryption Connection String in web.config Image

This is attached example's screen. On first button's click you can encrypt the connection string (app settings). After click on Encrypt Button you can check the effect on string in web.config.

Click here to see the working example in video



http://
http://

Contributed by:
Rohit kakria
I am software developer, moderator of xpode.com

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=35

Click here to go on website