DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: How to handle encryption decription of connection string ?  (Read 5,266 times)

gatewaytl

  • Participant
  • Joined in 2008
  • *
  • Posts: 1
How to handle encryption decription of connection string ?
« on: October 16, 2008, 08:59 AM »
Hi Friends,

I have created two functions that encrypt and decrypt the connection string in web.config. But whenever I want to use connection string. I have to always decrypt web.config and then again encrypt it back. Does there any other way which i can use.

I'm using section.SectionInformation.ProtectSection(" <encryption configuration provider> ") and section.SectionInformation.UnprotectSection()

CWuestefeld

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,009
    • Participated in NANY Challenge Once
Re: How to handle encryption decription of connection string ?
« Reply #1 on: October 16, 2008, 01:54 PM »
You can set things up so that the configuration section provider does the decryption for you. See this article.

Obviously, you (as the developer) need to do the initial work to encrypt the data and put it into the .config in the first place.

And, of course, if you've got a farm then each machine will by default have its own machine key for encrypt/decrypt, which would necessitate separately encrypted .config files for each machine, and that's no good. You'll need to set a different key, as described here.


Original address: https://www.donationcoder.com/forum/index.php?topic=15365.0