Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2008

Tip: Looking for answers? Try searching our database.

Encrypting and Decrypting AppConfig

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dilum - 25 Jul 2008 11:17 GMT
Hi,

    You can encrypt and decrypt AppConfig using the
"ConfigurationSection.SectionInformation.ProtectSection" method as follows.

//To Encrypt
 Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
               ConfigurationSection cons = config.AppSettings;
               
cons.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                cons.SectionInformation.
               cons.SectionInformation.ForceSave = true;
               config.Save(ConfigurationSaveMode.Full);

//To Decrypt
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
               ConfigurationSection cons = config.AppSettings;
               cons.SectionInformation.UnprotectSection();
               cons.SectionInformation.ForceSave = true;
               config.Save(ConfigurationSaveMode.Full);

But the limitation here is that it is machine specific, in the sense that
you can only decrypt in the same machine where you encrypted it. For an
example say that you want to deliver a solution to a customer with sections
in AppConfig encrypted, once you encrypted it in the developer pc, you wont
be able to access information in AppConfig in client's pc even through the
program.

So this is not possible if the machines are changed in the process. Seems it
takes internal machine specific keys to do the encryption and seems there is
no way to specify a custom key which can be delivered to the customer for
decryption. Even the class "SectionInformation" is seeled so that cannot
derive it and do any modifiations.

One way to overcome this is by, encrypting it while installing using a post
action command in the Setup project. So then it will become machine specific
and can decrypted as needed. But what I want to know is, is there any other
work arround for this? I would like to know all the other ways if there are
possibilities to do this.

Please let me know if you know anything regarding this.

Thank you
Dilum
Dirk Michaelsen - 25 Jul 2008 11:44 GMT
Hi Dilum,

use RsaProtectedConfigurationProvider instead of
DataProtectionConfigurationProvider

for Details start reading here:
http://msdn.microsoft.com/en-us/library/cc511527.aspx

Dirk

>Hi,
>
[quoted text clipped - 42 lines]
>Thank you
>Dilum

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.