Encrypt and Decrypt configuration files using Code

Encrypt and Decrypt configuration files using Code

How to encrypt connection string in asp.net stored in web.config.

Using System.web.configuration;
Protected void button_click(object sender,eventargs e)
{
string webconfigpath=”~”;
configuration config=webconfigurationmanager.openwebconfiguration(webconfigpath);
configurationsection configsection=config.Getsection(”connectionstrings”);
configsection.sectionInformation.protectsection(”Dataprotectionconfigurationprovider”);
config.save();
}

How to decrypt connection string in asp.net stored in web.config.

Using System.web.configuration;
Protected void button_click(object sender,eventargs e)
{
string webconfigpath=”~”;
configuration config=webconfigurationmanager.openwebconfiguration(webconfigpath);
configurationsection configsection=config.Getsection(”connectionstrings”);
configsection.sectionInformation.Unprotectsection();
config.save();

One Response to “Encrypt and Decrypt configuration files using Code”

  1. Feng Shui Bedroom Says:

    Feng Shui Bedroom

    Feng Shui Bedroom

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.