- This topic has 0 replies, 2 voices, and was last updated 11 years, 3 months ago by
Nitesh.
Viewing 3 posts - 1 through 3 (of 3 total)
- AuthorPosts
- February 2, 2012 at 6:49 am #3431
Nitesh
MemberHow can i Encrypt or Decrypt Connection Strings in web.config file using ASP.NET
February 2, 2012 at 12:16 pm #3436Pavan
MemberHi Nitesh,
Encrypt and Decrypt Connection Strings is very usefully for security point.Like when we are developing a application which secured then connection string Encrypt and Decrypt is one of steps.Define these string at top of page before page load.
string provider = "RSAProtectedConfigurationProvider"; string section = "connectionStrings";
Encrypt connection string code below:
public void Encrypt_connection() { Configuration confg = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); ConfigurationSection configSect = confg.GetSection(section); if (configSect != null) { configSect.SectionInformation.ProtectSection(provider); confg.Save(); } }
Decrypt connection string code below:
public void Decrypt_connection() { Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); ConfigurationSection configSect = config.GetSection(section); if (configSect.SectionInformation.IsProtected) { configSect.SectionInformation.UnprotectSection(); config.Save(); } }
February 2, 2012 at 1:24 pm #3437Nitesh
Memberthanx a ton pawan.
it just used the same code in my website and it wordked very first time
thanx again - AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.