How to encrypt web config?
<p>I wanted to encrypt the connection string section in the web config.</p>

<p>I did it using visual studio command prompt using this command.</p>

<p>aspnet_regiis.exe -pef “connectionStrings” C:\Projects\DemoApplication</p>

<p>and it encrypted the section and it worked fine.</p>

<p>and I did the same thing using code behind calling this method.it also worked fine but it give me wrong cipher value and I decripted it and matched with previous decript value and those are different.</p>

<pre><code>        string provider = "RsaProtectedConfigurationProvider";
        string section = "connectionStrings";

        System.Configuration.Configuration confg = ConfigurationManager.OpenExeConfiguration(txtLocation.Text + @"\web.config"); ;
        System.Configuration.ConfigurationSection configSect = confg.GetSection(section) as ConnectionStringsSection;
        if (configSect != null)
        {
            configSect.SectionInformation.ProtectSection(provider);
            confg.Save();
        }
</code></pre>

<p><strong>My question is why the two way of encrypting generate different values. even if both using the same provider "RsaProtectedConfigurationProvider"</strong></p>
